import{d as M,ai as t,r as T,b7 as W,b8 as q,b9 as A,o as s,c as l,g as d,w as F,a as n,a0 as P,ax as R,h as p,aG as V,ba as G,F as L,t as h,R as r,bb as H,i as J,k as K,__tla as N}from"./index-7d5b26d3.js";import{c as O,__tla as Q}from"./index-ac2a9b6d.js";import{u as X,__tla as Y}from"./useMessage-c81eaa5b.js";let S,Z=Promise.all([(()=>{try{return N}catch{}})(),(()=>{try{return Q}catch{}})(),(()=>{try{return Y}catch{}})()]).then(async()=>{let f,g,y,_,b,k,v;f={class:"upload-box"},g=["src"],y={key:0},_={key:0},b={key:0},k={key:1,class:"upload-empty"},v={class:"el-upload__tip"},S=M({name:"UploadImg",__name:"SPuUploadImg",props:{modelValue:t.string.def(""),updateUrl:t.string.def("https://sh.letcgo.com/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:B}){const u=e,{t:m}=J(),c=X(),w=T("id-"+W()),x=B,U=()=>{x("update:modelValue","")},C=T({Authorization:"Bearer "+q(),"tenant-id":A()}),$=()=>{const a=document.querySelector(`#${w.value} .el-upload__input`);a&&a.dispatchEvent(new MouseEvent("click"))},E=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},I=a=>{c.success("\u4E0A\u4F20\u6210\u529F"),x("update:modelValue",a.data)},j=()=>{c.notifyError("\u56FE\u7247\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u60A8\u91CD\u65B0\u4E0A\u4F20\uFF01")};return(a,i)=>{const o=K,D=G;return s(),l("div",f,[d(D,{id:n(w),accept:e.fileType.join(","),action:e.updateUrl,"before-upload":E,class:P(["upload",e.drag?"no-border":""]),drag:e.drag,headers:n(C),multiple:!1,"on-error":j,"on-success":I,"show-file-list":!1,style:R({width:e.width,height:e.height})},{default:F(()=>[e.modelValue?(s(),l(L,{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",y,h(n(m)("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",_,h(n(m)("action.detail")),1)):r("",!0)]),e.showDelete&&!e.disabled?(s(),l("div",{key:1,class:"handle-icon",onClick:U},[d(o,{icon:"ep:delete"}),e.showBtnText?(s(),l("span",b,h(n(m)("action.del")),1)):r("",!0)])):r("",!0)])],64)):(s(),l("div",k,[V(a.$slots,"empty",{},()=>[d(o,{icon:"ep:plus"})],!0)]))]),_:3},8,["id","accept","action","class","drag","headers","style"]),p("div",v,[V(a.$slots,"tip",{},void 0,!0)])])}}})});export{S as _,Z as __tla};
