import{d as A,ac as t,r as T,bA as L,bB as M,bC as W,o as s,c as l,f as d,w as q,a as n,T as P,g as p,aC as V,bD as F,F as G,t as m,a0 as r,aL as H,h as J,j as K,__tla as N}from"./index-8dc1e40a.js";import{c as O,__tla as Q}from"./index-519182c1.js";import{u as R,__tla as X}from"./useMessage-7a27dd80.js";let B,Y=Promise.all([(()=>{try{return N}catch{}})(),(()=>{try{return Q}catch{}})(),(()=>{try{return X}catch{}})()]).then(async()=>{let _,g,h,y,b,v,k;_={class:"upload-box"},g=["src"],h={key:0},y={key:0},b={key:0},v={key:1,class:"upload-empty"},k={class:"el-upload__tip"},B=A({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: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(e,{emit:C}){const u=e,{t:f}=J(),c=R(),w=T("id-"+L()),x=C,S=()=>{x("update:modelValue","")},U=T({Authorization:"Bearer "+M(),"tenant-id":W()}),$=()=>{const a=document.querySelector(`#${w.value} .el-upload__input`);a&&a.dispatchEvent(new MouseEvent("click"))},j=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},D=a=>{c.success("\u4E0A\u4F20\u6210\u529F"),x("update:modelValue",a.data)},E=()=>{c.notifyError("\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01")};return(a,i)=>{const o=K,I=F;return s(),l("div",_,[d(I,{id:n(w),accept:e.fileType.join(","),action:e.updateUrl,"before-upload":j,class:P(["upload",e.drag?"no-border":""]),drag:e.drag,headers:n(U),multiple:!1,"on-error":E,"on-success":D,"show-file-list":!1},{default:q(()=>[e.modelValue?(s(),l(G,{key:0},[p("img",{src:e.modelValue,class:"upload-image"},null,8,g),p("div",{class:"upload-handle",onClick:i[1]||(i[1]=H(()=>{},["stop"]))},[e.disabled?r("",!0):(s(),l("div",{key:0,class:"handle-icon",onClick:$},[d(o,{icon:"ep:edit"}),e.showBtnText?(s(),l("span",h,m(n(f)("action.edit")),1)):r("",!0)])),p("div",{class:"handle-icon",onClick:i[0]||(i[0]=Z=>{return z=e.modelValue,void O({zIndex:9999999,urlList:[z]});var z})},[d(o,{icon:"ep:zoom-in"}),e.showBtnText?(s(),l("span",y,m(n(f)("action.detail")),1)):r("",!0)]),e.showDelete&&!e.disabled?(s(),l("div",{key:1,class:"handle-icon",onClick:S},[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"]),p("div",k,[V(a.$slots,"tip",{},void 0,!0)])])}}})});export{B as _,Y as __tla};
