import{d as G,ar as t,r as T,d0 as M,c_ as W,c$ as q,o as s,c as l,f as d,B as A,a as n,ac as F,aG as P,C as p,aN as V,bi as L,F as N,G as m,D as r,aD as Q,Q as H,_ as J,__tla as K}from"./index-92ad187a.js";import{c as O,__tla as R}from"./index-d9067f1c.js";import{u as X,__tla as Y}from"./useMessage-d9788660.js";let B,Z=Promise.all([(()=>{try{return K}catch{}})(),(()=>{try{return R}catch{}})(),(()=>{try{return Y}catch{}})()]).then(async()=>{let h,_,y,g,b,v,k;h={class:"upload-box"},_=["src"],y={key:0},g={key:0},b={key:0},v={key:1,class:"upload-empty"},k={class:"el-upload__tip"},B=G({name:"UploadImg",__name:"SPuUploadImg",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:{type:String,default:"60px"},width:t.string.def("104px"),borderradius:t.string.def("8px"),showDelete:t.bool.def(!0),showBtnText:t.bool.def(!0)},emits:["update:modelValue"],setup(e,{emit:S}){const u=e,{t:f}=H(),c=X(),w=T("id-"+M()),x=S,$=()=>{x("update:modelValue","")},C=T({Authorization:"Bearer "+W(),"tenant-id":q()}),D=()=>{const a=document.querySelector(`#${w.value} .el-upload__input`);a&&a.dispatchEvent(new MouseEvent("click"))},U=a=>{const i=a.size/1024/1024<u.fileSize,o=u.fileType;return o.includes(a.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`),o.includes(a.type)&&i},E=a=>{c.success("\u4E0A\u4F20\u6210\u529F"),x("update:modelValue",a.data)},I=()=>{c.notifyError("\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01")};return(a,i)=>{const o=J,j=L;return s(),l("div",h,[d(j,{id:n(w),accept:e.fileType.join(","),action:e.updateUrl,"before-upload":U,class:F(["upload",e.drag?"no-border":""]),drag:e.drag,headers:n(C),multiple:!1,"on-error":I,"on-success":E,"show-file-list":!1,style:P({width:e.width,height:e.height})},{default:A(()=>[e.modelValue?(s(),l(N,{key:0},[p("img",{src:e.modelValue,class:"upload-image"},null,8,_),p("div",{class:"upload-handle",onClick:i[1]||(i[1]=Q(()=>{},["stop"]))},[e.disabled?r("",!0):(s(),l("div",{key:0,class:"handle-icon",onClick:D},[d(o,{icon:"ep:edit"}),e.showBtnText?(s(),l("span",y,m(n(f)("action.edit")),1)):r("",!0)])),p("div",{class:"handle-icon",onClick:i[0]||(i[0]=ee=>{return z=e.modelValue,void O({zIndex:9999999,urlList:[z]});var z})},[d(o,{icon:"ep:zoom-in"}),e.showBtnText?(s(),l("span",g,m(n(f)("action.detail")),1)):r("",!0)]),e.showDelete&&!e.disabled?(s(),l("div",{key:1,class:"handle-icon",onClick:$},[d(o,{icon:"ep:delete"}),e.showBtnText?(s(),l("span",b,m(n(f)("action.del")),1)):r("",!0)])):r("",!0)])],64)):(s(),l("div",v,[V(a.$slots,"empty",{},()=>[d(o,{icon:"ep:plus"})],!0)]))]),_:3},8,["id","accept","action","class","drag","headers","style"]),p("div",k,[V(a.$slots,"tip",{},void 0,!0)])])}}})});export{B as _,Z as __tla};
