2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
import{a as z}from"./index-D6Ls7Izj.js";import{d as Re,o as We,w as Ge,b as g,c as s,f as l,r as u,aW as Je,b1 as he,i as _,b2 as Qe,b3 as ae,b4 as J,Q as Ye,M as Ze,D as ve,j as i,aY as He,y as k,z as x,m as c,s as $,g as w,t as C,B as Ke,l as f,am as Xe,aZ as et,W as tt,a_ as Ie,F as at,p as lt,q as st,ay as ot,S as it,ax as nt,e as me,a$ as rt,b5 as ut,x as dt,b6 as pt,aP as ct,G as vt}from"./index-bPsB4P3d.js";import{u as mt}from"./permission-BlWK9fJt.js";import"./permission-B3m70OCX.js";const gt={class:"products"},ft={key:0,class:"product-images"},bt={key:1},yt={key:2,style:{color:"#cf1322","font-weight":"600"}},_t={key:0},ht=["src"],It={class:"product-images"},kt=Re({__name:"ProductsView",setup(wt){const{hasPermission:le,loadUserPermissions:ke}=mt(),se=u(!1),oe=u(""),ge=u([]),L=u(!1),Q=u(!1),ie=u(!1),E=u(!1),ne=u(null),P=u([]),re=u(!1),R=u([]),ue=u(!1),W=u([]),de=u(!1),Y=u([]),pe=u(!1),Z=u(!1),fe=u(""),O=u([]),S=u([]),H=u({}),K=u([]),h=u({}),be=u(!1),ce=u(null),v=ve({shopId:void 0,title:"",description:"",imageFileIds:"",price:0,tags:[],approximateDuration:void 0,bookableArtists:[],availableCoupons:[]}),N=ve({current:1,pageSize:10,total:0,showSizeChanger:!0,showQuickJumper:!0,showTotal:e=>`共 ${e} 条`}),o=ve({shopId:void 0,title:"",description:"",imageFileIds:"",price:0,tags:[],approximateDuration:void 0,bookableArtists:[],availableCoupons:[]}),we={title:[{required:!0,message:"请输入作品名称",trigger:"blur"}],description:[{required:!0,message:"请输入作品描述",trigger:"blur"}],price:[{required:!0,message:"请输入价格",trigger:"blur"}],shopId:[{required:!0,message:"请选择店铺",trigger:"change"}],tags:[{required:!0,message:"请选择标签",trigger:"change"}],bookableArtists:[{required:!0,message:"请选择美甲师",trigger:"change"}]},Ae=[{title:"图片",key:"image",width:150},{title:"作品名称",dataIndex:"title",key:"title"},{title:"所属店铺",key:"shop",width:150},{title:"描述",dataIndex:"description",key:"description"},{title:"价格",key:"price",width:100},{title:"预计时长",dataIndex:"approximateDuration",key:"approximateDuration",width:120},{title:"点赞",dataIndex:"likeCount",key:"likeCount",width:80},{title:"收藏",dataIndex:"collectCount",key:"collectCount",width:80},{title:"创建时间",dataIndex:"createTime",key:"createTime"},{title:"操作",key:"actions",width:150,fixed:"right"}],xe=e=>{const t=P.value.find(d=>d.id===e);return t?t.shopName:"未知店铺"},X=()=>{try{const e=localStorage.getItem("adminUserInfo");if(e){const t=JSON.parse(e);return be.value=t.type===4,t}}catch(e){console.error("获取当前用户信息失败",e)}return null},Ce=()=>{const e=X();return e&&e.type===2},Se=async()=>{re.value=!0;try{const e=X();if(e&&e.type===3&&e.shopId)P.value=[],o.shopId=e.shopId;else{const d=await Je.listAllShops()||[];e&&e.type!==4&&e.shopId?(P.value=d?.filter(b=>b.id===e.shopId)||[],o.shopId=e.shopId):P.value=d||[]}}catch(e){console.error("获取店铺列表失败:",e)}finally{re.value=!1}},ye=async e=>{ue.value=!0;try{let t;e?t=await he.listTagsByShopId(e):t=await he.listAllTags(),R.value=t||[]}catch(t){console.error("获取标签列表失败",t),_.error("获取标签列表失败")}finally{ue.value=!1}},ee=async e=>{de.value=!0;try{const t=await pt.listArtists(e);W.value=t||[]}catch(t){console.error("获取美甲师列表失败",t),_.error("获取美甲师列表失败")}finally{de.value=!1}},Ue=async()=>{pe.value=!0;try{const e=await Qe.listAllCoupons(),t=typeof e=="object"&&"data"in e?e.data:e;Y.value=t||[]}catch(e){console.error("获取优惠券列表失败",e),_.error("获取优惠券列表失败")}finally{pe.value=!1}},G=async()=>{se.value=!0;try{const e=X(),t={page:N.current,size:N.pageSize,keyword:oe.value};e&&e.type!==4&&e.shopId&&(t.shopId=e.shopId);const d=await ae.listProducts(t);ge.value=d?.list||[],N.total=d?.total||0,await De(d?.list||[])}catch{_.error("获取作品列表失败")}finally{se.value=!1}},De=async e=>{for(const t of e)if(t.imageFileIds){const d=t.imageFileIds.split(","),b=[];for(const n of d)if(n)try{if(!h.value[n]){const A=await J.getSigned
|