UploadImg-1a4a67d6.js 3.2 KB

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