import{d as j,f as i,e as k,w as z,n as D,U as u,a2 as o,a3 as y,k as b,af as U,ad as w,a4 as F,a5 as V,V as C,G as J}from"./vue-vendor-CxLCUzY4.js";import{aO as R,ai as G}from"./antd-vue-vendor-CahNzUUa.js";import{useRuleFormItem as H}from"./useFormItem-IOFWTdED.js";import{a5 as x,aE as K,b as L,aF as Q,u as W,aG as X,F as T,_ as Y}from"./index-Cy4uayzW.js";const{createMessage:I,createErrorModal:fe}=W(),Z=j({name:"JImageUpload",components:{LoadingOutlined:G,UploadOutlined:R},inheritAttrs:!1,props:{value:T.oneOfType([T.string,T.array]),listType:{type:String,required:!1,default:"picture-card"},text:{type:String,required:!1,default:"上传"},bizPath:{type:String,required:!1,default:"temp"},disabled:{type:Boolean,required:!1,default:!1},fileMax:{type:Number,required:!1,default:1}},emits:["options-change","change","update:value"],setup(a,{emit:l,refs:M}){const _=i([]),O=x(),[c]=H(a,"value","change",_),m=e=>{if(e.lastIndexOf("\\")>=0){let t=new RegExp("\\\\","g");e=e.replace(t,"/")}return e.substring(e.lastIndexOf("/")+1)},p=K(),g=i(!1),r=i(!0);let n=i([]);const d=i(""),h=i(!1),E=k(()=>a.fileMax>1||a.fileMax===0),N=k(()=>a.fileMax===0?!0:n.value.length<a.fileMax);z(()=>a.value,(e,t)=>{e&&e instanceof Array&&(e=e.join(",")),r.value==!0&&P(e)},{immediate:!0});function P(e){if(!e||e.length==0){n.value=[];return}let t=[];e.split(",").forEach(s=>{let f=L(s);t.push({uid:Q(10),name:m(s),status:"done",url:f,response:{status:"history",message:s}})}),n.value=t}function $(e){if(e.type.indexOf("image")<0)return I.info("请上传图片"),!1}function q({file:e,fileList:t,event:S}){r.value=!1,e.status==="error"&&I.error(`${e.name} 上传失败.`);let s=[],f=0;e.status!="uploading"&&(t.forEach(v=>{v.status==="done"&&s.push(v.response.message),v.status!="uploading"&&f++}),e.status==="removed"&&void 0,f==t.length&&(c.value=s.join(","),l("update:value",s.join(",")),D(()=>{r.value=!0})))}function ie(e){}function A(e){d.value=e.url||e.thumbUrl,h.value=!0}function oe(){if(n.length>0){let e=n[0].url;return L(e,null)}}function B(){h.value=!1}return{state:c,attrs:O,previewImage:d,previewVisible:h,uploadFileList:n,multiple:E,headers:p,loading:g,uploadUrl:X,beforeUpload:$,uploadVisible:N,handlePreview:A,handleCancel:B,handleChange:q}}}),ee={class:"clearfix"},ae={key:0},te={key:0},ne={class:"ant-upload-text"},se=["src"];function le(a,l,M,_,O,c){const m=u("LoadingOutlined"),p=u("UploadOutlined"),g=u("a-button"),r=u("a-upload"),n=u("a-modal");return o(),y("div",ee,[b(r,{listType:a.listType,accept:"image/*",multiple:a.multiple,action:a.uploadUrl,headers:a.headers,data:{biz:a.bizPath},fileList:a.uploadFileList,"onUpdate:fileList":l[0]||(l[0]=d=>a.uploadFileList=d),beforeUpload:a.beforeUpload,disabled:a.disabled,onChange:a.handleChange,onPreview:a.handlePreview},{default:U(()=>[a.uploadVisible?(o(),y("div",ae,[a.listType=="picture-card"?(o(),y("div",te,[a.loading?(o(),w(m,{key:0})):(o(),w(p,{key:1})),F("div",ne,V(a.text),1)])):C("",!0),a.listType=="picture"?(o(),w(g,{key:1,disabled:a.disabled},{default:U(()=>[b(p),J(" "+V(a.text),1)]),_:1},8,["disabled"])):C("",!0)])):C("",!0)]),_:1},8,["listType","multiple","action","headers","data","fileList","beforeUpload","disabled","onChange","onPreview"]),b(n,{open:a.previewVisible,footer:null,onCancel:l[1]||(l[1]=d=>a.handleCancel())},{default:U(()=>[F("img",{alt:"example",style:{width:"100%"},src:a.previewImage},null,8,se)]),_:1},8,["open"])])}const ce=Y(Z,[["render",le],["__scopeId","data-v-437012ef"]]);export{ce as J};
