Files
JayuCloud/docs/product/Frontend/assets/ShopsView-Cy9kcJtV.js
T

2 lines
14 KiB
JavaScript
Raw Normal View History

2026-03-21 17:08:36 +08:00
import{b as L}from"./index-D6Ls7Izj.js";import{d as Ee,o as Re,b as h,c as n,f as o,r as u,aW as W,i as m,Q as qe,M as Ae,D as le,b4 as _,j as v,aY as De,y as G,z as J,m as I,s as S,g as b,B as We,l as Q,am as Ge,aZ as Je,W as Qe,a_ as oe,F as Ye,p as Ze,q as Ke,ay as Xe,e as w,al as es,ax as ss,b5 as as,aP as ts,G as ns}from"./index-bPsB4P3d.js";import{u as ls}from"./permission-BlWK9fJt.js";import"./permission-B3m70OCX.js";const os={class:"shops"},is={key:0,class:"shop-images"},rs={key:1,class:"shop-banner"},us={key:0,class:"no-banner"},ds={class:"business-hours-picker"},ps={key:0},vs=["src"],cs={key:0},ms=["src"],gs={class:"shop-images"},fs={key:0,class:"no-banner"},hs={class:"shop-images"},Is=Ee({__name:"ShopsView",setup(bs){const{hasPermission:O,loadUserPermissions:Ie}=ls(),Y=u(!1),Z=u(""),ie=u([]),j=u(!1),T=u(!1),K=u(!1),E=u(!1),R=u(),X=u(null),be=u(!1),U=u([]),F=u([]),q=u(!1),re=u(""),H=u([]),k=u([]),d=u({}),ee=u({}),se=u({}),V=u([]),M=u([]),A=u(!1),ue=u(""),N=u(""),B=u(""),y=le({shopName:"",description:"",address:"",businessHours:"",coverImageFileId:"",imageFileIds:""}),C=le({current:1,pageSize:10,total:0,showSizeChanger:!0,showQuickJumper:!0,showTotal:s=>`共 ${s} 条`}),c=le({shopName:"",description:"",address:"",businessHours:"",coverImageFileId:"",imageFileIds:""}),ye={shopName:[{required:!0,message:"请输入店铺名称",trigger:"blur"}],description:[{required:!0,message:"请输入店铺描述",trigger:"blur"}],address:[{required:!0,message:"请输入店铺地址",trigger:"blur"}],businessHours:[{validator:async()=>!N.value||!B.value?Promise.reject("请选择营业开始和结束时间"):N.value>=B.value?Promise.reject("营业结束时间必须晚于开始时间"):Promise.resolve(),trigger:"change"}]},_e=[{title:"图片",key:"image",width:150},{title:"Banner",key:"banner",width:200},{title:"店铺名称",dataIndex:"shopName",key:"shopName"},{title:"店铺描述",dataIndex:"description",key:"description"},{title:"店铺地址",dataIndex:"address",key:"address"},{title:"营业时间",dataIndex:"businessHours",key:"businessHours"},{title:"创建时间",dataIndex:"createTime",key:"createTime"},{title:"操作",key:"actions",width:150,fixed:"right"}],we=()=>{try{const s=localStorage.getItem("adminUserInfo");if(s){const e=JSON.parse(s);return be.value=e.type===4,e}}catch(s){console.error("获取当前用户信息失败",s)}return null},Fe=async s=>{for(const e of s){if(e.imageFileIds){const p=e.imageFileIds.split(","),r=[];for(const a of p)if(a)try{if(!d.value[a]){const l=await _.getSignedUrl(Number(a||"0"));d.value[a]=l}r.push(d.value[a])}catch(l){console.error("获取签名链接失败:",l),r.push(L)}e.id!==void 0&&(ee.value[e.id]=r)}else e.id!==void 0&&(ee.value[e.id]=[]);if(e.coverImageFileId){const p=e.coverImageFileId.split(","),r=[];for(const a of p)if(a)try{if(!d.value[a]){const l=await _.getSignedUrl(Number(a||"0"));d.value[a]=l}r.push(d.value[a])}catch(l){console.error("获取签名链接失败:",l),r.push(L)}e.id!==void 0&&(se.value[e.id]=r)}else e.id!==void 0&&(se.value[e.id]=[])}},de=s=>{const e=("id"in s,s.id);return e!==void 0?ee.value[e]||[]:[]},pe=s=>{const e=("id"in s,s.id);return e!==void 0?se.value[e]||[]:[]},$=async()=>{Y.value=!0;try{const s=we(),e={page:C.current,size:C.pageSize,keyword:Z.value};s&&s.type!==4&&s.shopId&&(e.shopId=s.shopId);const p=await W.listShops(e),r=typeof p=="object"&&"list"in p?p:p.data;ie.value=r.list||[],C.total=r.total||0,await Fe(r.list||[])}catch{m.error("获取店铺列表失败")}finally{Y.value=!1}},ke=()=>{C.current=1,$()},xe=s=>{C.current=s.current,C.pageSize=s.pageSize,$()},ve=s=>{const e=s.type.startsWith("image/");e||m.error("只能上传图片文件!");const p=s.size/1024/1024<2;return p||m.error("图片大小不能超过 2MB!"),e&&p},Se=async s=>{const{file:e,onSuccess:p,onError:r}=s;try{const a=await _.uploadFile(e),l=typeof a=="object"&&"id"in a?a:a.data;F.value.push(String(l.id)),c.coverImageFileId=F.value.join(","),p({url:String(l.id)}),m.success("Banner上传成功")}catch(a){console.error("Banner上传失败:",a),r(a),m.error("Banner上传失败")}