import{_ as K,b as O,r as d,ah as Q,Z as W,$ as P,o as f,c as v,p as l,q as s,v as i,P as b,x as C,aH as X,n as m,F as q,A as Y,N as ee,C as z,s as M,l as ae,ak as oe,bv as te,D as le}from"./index.8d733f79.js";import{E as ne}from"./el-infinite-scroll.6411a926.js";import{E as se}from"./el-progress.ee3fa77d.js";import{b as ie,c as ce,e as de}from"./deviceType.30ac56e5.js";import"./throttle.04d7163a.js";const me=["infinite-scroll-disabled"],re={class:"df",style:{"flex-wrap":"wrap"}},ue=["onClick"],ge=["src"],pe={class:"img-item-actions"},_e=["onClick"],fe=["onClick"],ve={class:"dialog-footer"},he=["src"],Ie={__name:"imageLib",emits:["confirm","deleteImg"],setup(we,{expose:S,emit:y}){const{t:$}=O(),{proxy:k}=le(),N="./",r=d(!1),E=d(""),g=d(!1),p=Q({pageNo:0,pageSize:12}),h=d(!1),_=d(!1),c=d([]),u=d(),U=W(()=>h.value||_.value),F=()=>{r.value=!0,u.value=null,p.pageNo=0,_.value=!1,V()},V=()=>{p.pageNo++,h.value=!0,ie(p).then(e=>{var a;h.value=!1,e.data.content.length&&e.data.content.forEach(o=>{const n=`${N}/equipment-web/file/downloadImage?fileId=${o.imageId}`;c.value.push({id:o.id,url:n,imageId:o.imageId,imageName:o.imageName})}),((a=e.data.content)==null?void 0:a.length)<p.pageSize&&(_.value=!0)})},j=e=>{E.value=e.url,g.value=!0},R=e=>{console.log(222,e),k.$modal.confirm($("confirmDelete")).then(()=>{ce({id:e.id}).then(()=>{c.value=c.value.filter(a=>a.id!==e.id),y("deleteImg",e.imageId)})}).catch(()=>{})},A=e=>{console.log(222,e);const a=e.file,o=new FormData;o.append("file",a),de(o).then(n=>{if(n.data){const w=`${N}/equipment-web/file/downloadImage?fileId=${n.data.imageId}`;c.value.unshift({id:n.data.id,url:w,imageId:n.data.imageId,imageName:n.data.imageName||e.file.name}),_.value||c.value.pop()}})},H=e=>{u.value=e},T=()=>{if(!u.value){k.$modal.msgError($("deviceImgP"));return}y("confirm",u.value),I()};function I(){r.value=!1}const Z=()=>{c.value=[]};return S({showModal:F}),(e,a)=>{const o=ae,n=se,w=P("zoom-in"),x=oe,G=P("Delete"),D=te,J=ne;return f(),v(q,null,[l(D,{title:e.$t("imageLib"),modelValue:m(r),"onUpdate:modelValue":a[0]||(a[0]=t=>M(r)?r.value=t:null),style:{width:"640px"},onClose:I,onClosed:Z},{footer:s(()=>[i("div",ve,[l(o,{onClick:I},{default:s(()=>[b(C(e.$t("cancel")),1)]),_:1}),l(o,{type:"primary",onClick:T},{default:s(()=>[b(C(e.$t("confirm")),1)]),_:1})])]),default:s(()=>[i("div",null,[l(n,{action:"#","http-request":A,accept:".jpg,.png,jpeg",style:{"margin-bottom":"16px"}},{default:s(()=>[l(o,{type:"primary"},{default:s(()=>[b(C(e.$t("uploadImg")),1)]),_:1})]),_:1}),X((f(),v("div",{"infinite-scroll-disabled":m(U),style:{height:"240px",overflow:"auto"}},[i("div",re,[(f(!0),v(q,null,Y(m(c),t=>{var L;return f(),v("div",{class:ee(["img-wrap",((L=m(u))==null?void 0:L.id)===t.id&&"active-img"]),key:t.id,onClick:B=>H(t)},[i("img",{src:t.url},null,8,ge),i("span",pe,[i("span",{class:"icon",onClick:z(B=>j(t),["stop"])},[l(x,null,{default:s(()=>[l(w)]),_:1})],8,_e),i("span",{class:"icon",onClick:z(B=>R(t),["stop"])},[l(x,null,{default:s(()=>[l(G)]),_:1})],8,fe)])],10,ue)}),128))])],8,me)),[[J,V]])])]),_:1},8,["title","modelValue"]),l(D,{modelValue:m(g),"onUpdate:modelValue":a[1]||(a[1]=t=>M(g)?g.value=t:null)},{default:s(()=>[i("img",{src:m(E),alt:"Preview Image",class:"img-pre"},null,8,he)]),_:1},8,["modelValue"])],64)}}},Ne=K(Ie,[["__scopeId","data-v-c1a85fe0"]]);export{Ne as default};
