UploadImg-46306ddf.js 3.2 KB

1
  1. import{d as A,as as s,d3 as F,r as T,d2 as M,d0 as W,d1 as q,o as t,c as d,f as o,A as L,a as n,ad as P,B as p,aO as V,bj as O,F as Q,E as f,a3 as r,aE as G,P as H,Q as J,_ as K,__tla as N}from"./index-54aa57d8.js";import{c as R,__tla as X}from"./index-1a846221.js";import{u as Y,__tla as Z}from"./useMessage-f56cafbb.js";let B,aa=Promise.all([(()=>{try{return N}catch{}})(),(()=>{try{return X}catch{}})(),(()=>{try{return Z}catch{}})()]).then(async()=>{let _,h,g,y,b,v,w;_={class:"upload-box"},h=["src"],g={key:0},y={key:0},b={key:0},v={key:1,class:"upload-empty"},w={class:"el-upload__tip"},B=K(A({name:"UploadImg",__name:"UploadImg",props:{modelValue:s.string.def(""),updateUrl:s.string.def("https://zxpt.newfeifan.cn/admin-api/infra/file/upload"),drag:s.bool.def(!0),disabled:s.bool.def(!1),fileSize:s.number.def(5),fileType:s.array.def(["image/jpeg","image/png","image/gif"]),height:s.string.def("150px"),width:s.string.def("150px"),borderradius:s.string.def("8px"),showDelete:s.bool.def(!0),showBtnText:s.bool.def(!0)},emits:["update:modelValue"],setup(a,{emit:U}){F(e=>({"57417a1d-width":a.width,"57417a1d-height":a.height,"57417a1d-borderradius":a.borderradius}));const u=a,{t:m}=H(),c=Y(),x=T("id-"+M()),k=U,C=()=>{k("update:modelValue","")},E=T({Authorization:"Bearer "+W(),"tenant-id":q()}),I=()=>{const e=document.querySelector(`#${x.value} .el-upload__input`);e&&e.dispatchEvent(new MouseEvent("click"))},S=e=>{const i=e.size/1024/1024<u.fileSize,l=u.fileType;return l.includes(e.type)||c.notifyWarning("\u4E0A\u4F20\u56FE\u7247\u4E0D\u7B26\u5408\u6240\u9700\u7684\u683C\u5F0F\uFF01"),i||c.notifyWarning(`\u4E0A\u4F20\u56FE\u7247\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 ${u.fileSize}M\uFF01`),l.includes(e.type)&&i},$=e=>{c.success("\u4E0A\u4F20\u6210\u529F"),k("update:modelValue",e.data)},j=()=>{c.notifyError("\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01")};return(e,i)=>{const l=J,D=O;return t(),d("div",_,[o(D,{id:n(x),accept:a.fileType.join(","),action:a.updateUrl,"before-upload":S,class:P(["upload",a.drag?"no-border":""]),drag:a.drag,headers:n(E),multiple:!1,"on-error":j,"on-success":$,"show-file-list":!1},{default:L(()=>[a.modelValue?(t(),d(Q,{key:0},[p("img",{src:a.modelValue,class:"upload-image"},null,8,h),p("div",{class:"upload-handle",onClick:i[1]||(i[1]=G(()=>{},["stop"]))},[a.disabled?r("",!0):(t(),d("div",{key:0,class:"handle-icon",onClick:I},[o(l,{icon:"ep:edit"}),a.showBtnText?(t(),d("span",g,f(n(m)("action.edit")),1)):r("",!0)])),p("div",{class:"handle-icon",onClick:i[0]||(i[0]=ea=>{return z=a.modelValue,void R({zIndex:9999999,urlList:[z]});var z})},[o(l,{icon:"ep:zoom-in"}),a.showBtnText?(t(),d("span",y,f(n(m)("action.detail")),1)):r("",!0)]),a.showDelete&&!a.disabled?(t(),d("div",{key:1,class:"handle-icon",onClick:C},[o(l,{icon:"ep:delete"}),a.showBtnText?(t(),d("span",b,f(n(m)("action.del")),1)):r("",!0)])):r("",!0)])],64)):(t(),d("div",v,[V(e.$slots,"empty",{},()=>[o(l,{icon:"ep:plus"})],!0)]))]),_:3},8,["id","accept","action","class","drag","headers"]),p("div",w,[V(e.$slots,"tip",{},void 0,!0)])])}}}),[["__scopeId","data-v-57417a1d"],["__file","D:/zx/mall-newfeifan-zx-admin/src/components/UploadFile/src/UploadImg.vue"]])});export{B as _,aa as __tla};