UploadImg-90fe71c2.js 3.1 KB

1
  1. import{d as M,af as t,bB as W,r as T,bh as q,bi as A,bj as F,o as s,c as i,f as d,w as L,a as n,Y as O,g as p,aC as V,bk as P,F as R,t as m,O as r,aR as Y,h as G,_ as H,__tla as J}from"./index-2eab2d23.js";import{c as K,__tla as N}from"./index-d3f876ab.js";import{u as Q,__tla as X}from"./useMessage-171aa63e.js";import{_ as Z}from"./_plugin-vue_export-helper-1b428a4d.js";let B,aa=Promise.all([(()=>{try{return J}catch{}})(),(()=>{try{return N}catch{}})(),(()=>{try{return X}catch{}})()]).then(async()=>{let h,_,g,y,b,v,k;h={class:"upload-box"},_=["src"],g={key:0},y={key:0},b={key:0},v={key:1,class:"upload-empty"},k={class:"el-upload__tip"},B=Z(M({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:C}){W(e=>({"3047ba58":a.width,"823ed256":a.height,b75aca28:a.borderradius}));const u=a,{t:f}=G(),c=Q(),w=T("id-"+q()),x=C,U=()=>{x("update:modelValue","")},I=T({Authorization:"Bearer "+A(),"tenant-id":F()}),S=()=>{const e=document.querySelector(`#${w.value} .el-upload__input`);e&&e.dispatchEvent(new MouseEvent("click"))},$=e=>{const l=e.size/1024/1024<u.fileSize,o=u.fileType;return o.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`),o.includes(e.type)&&l},j=e=>{c.success("\u4E0A\u4F20\u6210\u529F"),x("update:modelValue",e.data)},E=()=>{c.notifyError("\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01")};return(e,l)=>{const o=H,D=P;return s(),i("div",h,[d(D,{id:n(w),accept:a.fileType.join(","),action:a.updateUrl,"before-upload":$,class:O(["upload",a.drag?"no-border":""]),drag:a.drag,headers:n(I),multiple:!1,"on-error":E,"on-success":j,"show-file-list":!1},{default:L(()=>[a.modelValue?(s(),i(R,{key:0},[p("img",{src:a.modelValue,class:"upload-image"},null,8,_),p("div",{class:"upload-handle",onClick:l[1]||(l[1]=Y(()=>{},["stop"]))},[a.disabled?r("",!0):(s(),i("div",{key:0,class:"handle-icon",onClick:S},[d(o,{icon:"ep:edit"}),a.showBtnText?(s(),i("span",g,m(n(f)("action.edit")),1)):r("",!0)])),p("div",{class:"handle-icon",onClick:l[0]||(l[0]=ea=>{return z=a.modelValue,void K({zIndex:9999999,urlList:[z]});var z})},[d(o,{icon:"ep:zoom-in"}),a.showBtnText?(s(),i("span",y,m(n(f)("action.detail")),1)):r("",!0)]),a.showDelete&&!a.disabled?(s(),i("div",{key:1,class:"handle-icon",onClick:U},[d(o,{icon:"ep:delete"}),a.showBtnText?(s(),i("span",b,m(n(f)("action.del")),1)):r("",!0)])):r("",!0)])],64)):(s(),i("div",v,[V(e.$slots,"empty",{},()=>[d(o,{icon:"ep:plus"})],!0)]))]),_:3},8,["id","accept","action","class","drag","headers"]),p("div",k,[V(e.$slots,"tip",{},void 0,!0)])])}}}),[["__scopeId","data-v-e1511cca"]])});export{B as _,aa as __tla};