wangxinhui
2024-11-06 8f392cc88b0768b74efca3b68785cf5aa1c38e70
1
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4e08765a"],{"0604":function(e,t,i){},"14cf":function(e,t,i){"use strict";i.r(t);var l=i("7a23");const s=e=>(Object(l["Q"])("data-v-10ef8528"),e=e(),Object(l["O"])(),e),a={class:"upload-container"},n={class:"input-btns",style:{"margin-bottom":"10px"}},o=["multiple"],c={key:0,class:"upload-img"},r={class:"operation"},h={class:"action"},d=["onClick"],f=["onClick"],u=s(()=>Object(l["o"])("div",{class:"mask"},null,-1)),p=["src","onerror"],m=s(()=>Object(l["o"])("i",{class:"el-icon-camera-solid"},null,-1)),b=[m],g={key:0},O={key:1},j={class:"upload-list"},v=["onClick"],x=["onClick"],y=s(()=>Object(l["o"])("i",{class:"el-icon-close"},null,-1)),k=[y];function C(e,t,i,s,m,y){const C=Object(l["W"])("el-button"),w=Object(l["W"])("el-alert");return Object(l["N"])(),Object(l["n"])("div",a,[Object(l["o"])("div",null,[Object(l["o"])("div",n,[Object(l["o"])("input",{ref:"input",type:"file",style:{display:"none"},onChange:t[0]||(t[0]=(...e)=>y.handleChange&&y.handleChange(...e)),multiple:i.multiple},null,40,o),i.img?(Object(l["N"])(),Object(l["n"])("div",c,[(Object(l["N"])(!0),Object(l["n"])(l["b"],null,Object(l["U"])(m.files,(e,t)=>(Object(l["N"])(),Object(l["n"])("div",{key:t,class:"img-item"},[Object(l["o"])("div",r,[Object(l["o"])("div",h,[Object(l["o"])("i",{class:"el-icon-view view",onClick:e=>y.previewImg(t)},null,8,d),Object(l["o"])("i",{class:"el-icon-delete remove",onClick:e=>y.removeFile(t)},null,8,f)]),u]),Object(l["o"])("img",{src:y.getImgSrc(e,t),onerror:m.errorImg},null,8,p)]))),128)),Object(l["ob"])(Object(l["o"])("div",{class:Object(l["D"])(["img-selector",y.getSelector()])},[Object(l["o"])("div",{class:"selector",onClick:t[1]||(t[1]=(...e)=>y.handleClick&&y.handleClick(...e))},b),i.autoUpload?Object(l["m"])("",!0):(Object(l["N"])(),Object(l["n"])("div",{key:0,class:Object(l["D"])(["s-btn",{readonly:m.changed}]),onClick:t[2]||(t[2]=(...e)=>y.upload&&y.upload(...e))},[Object(l["o"])("div",null,Object(l["bb"])(m.loadText),1)],2))],2),[[l["kb"],!i.autoUpload||i.autoUpload&&m.files.length<i.maxFile]])])):(Object(l["N"])(),Object(l["l"])(C,{key:1,onClick:y.handleClick},{default:Object(l["nb"])(()=>[Object(l["r"])("选择"+Object(l["bb"])(i.img?"图片":"文件"),1)]),_:1},8,["onClick"])),i.autoUpload||i.img?Object(l["m"])("",!0):(Object(l["N"])(),Object(l["l"])(C,{key:2,type:"info",disabled:m.changed,onClick:t[3]||(t[3]=e=>y.upload(!0)),loading:m.loadingStatus},{default:Object(l["nb"])(()=>[Object(l["r"])("上传文件")]),_:1},8,["disabled","loading"]))]),Object(l["V"])(e.$slots,"default",{},void 0,!0),i.desc?(Object(l["N"])(),Object(l["n"])("div",g,[Object(l["s"])(w,{title:y.getText()+"文件大小不超过"+(i.maxSize||3)+"M",type:"info","show-icon":""},null,8,["title"])])):Object(l["m"])("",!0),Object(l["V"])(e.$slots,"content",{},void 0,!0),i.img?Object(l["m"])("",!0):(Object(l["N"])(),Object(l["n"])("div",O,[Object(l["ob"])(Object(l["o"])("ul",j,[(Object(l["N"])(!0),Object(l["n"])(l["b"],null,Object(l["U"])(m.files,(e,t)=>(Object(l["N"])(),Object(l["n"])("li",{class:"list-file",key:t},[Object(l["o"])("a",null,[Object(l["o"])("span",{onClick:i=>y.fileOnClick(t,e)},[Object(l["o"])("i",{class:Object(l["D"])(y.format(e))},null,2),Object(l["r"])(" "+Object(l["bb"])(e.name),1)],8,v)]),Object(l["o"])("span",{onClick:e=>y.removeFile(t),class:"file-remove"},k,8,x)]))),128))],512),[[l["kb"],i.fileList]])])),Object(l["V"])(e.$slots,"tip",{},void 0,!0)])])}i("88a7"),i("271a"),i("5494"),i("14d9");var w={components:{},props:{desc:{type:Boolean,default:!1},fileInfo:{type:Array,default:()=>[]},downLoad:{type:Boolean,default:!0},multiple:{type:Boolean,default:!1},maxFile:{type:Number,default:5},maxSize:{type:Number,default:3},autoUpload:{type:Boolean,default:!0},img:{type:Boolean,default:!1},excel:{type:Boolean,default:!1},fileTypes:{type:Array,default:()=>[]},url:{type:String,default:""},uploadBefore:{type:Function,default:e=>!0},uploadAfter:{type:Function,default:(e,t)=>!0},onChange:{type:Function,default:e=>!0},fileList:{type:Boolean,default:!0},fileClick:{type:Function,default:(e,t,i)=>!0},removeBefore:{type:Function,default:(e,t,i)=>!0},append:{type:Boolean,default:!1},compress:{type:Boolean,default:!1}},data(){return{errorImg:'this.src="'+i("731d")+'"',changed:!1,model:!0,files:[],bigImg:"",loadingStatus:!1,loadText:"上传文件"}},created(){this.fileInfo&&(this.changed=!0),this.cloneFile(this.fileInfo)},watch:{fileInfo:{handler(e){this.cloneFile(e)},deep:!0}},methods:{cloneFile(e){this.files=e.map(e=>({name:e.name||this.getFileName(e.path),path:e.path}))},getFileName(e){if(!e)return"未定义文件名";let t=e.lastIndexOf("/");return e.substring(t+1)},previewImg(e){this.base.previewImg(this.getImgSrc(this.files[e]))},getSelector(){return this.autoUpload?"auto-selector":"submit-selector"},getImgSrc(e,t){return e.hasOwnProperty("path")?this.base.isUrl(e.path)?e.path:-1!=e.path.indexOf("/9j/")?"data:image/jpeg;base64,"+e.path:("/"==e.path.substr(0,1)&&(e.path=e.path.substr(1)),this.http.ipAddress+e.path):window.URL.createObjectURL(e)},fileOnClick(e,t){this.fileClick(e,t,this.files)&&this.downLoad&&(t.path?this.base.dowloadFile(t.path,t.name,{Authorization:this.$store.getters.getToken()},this.http.ipAddress):this.$message.error("请先上传文件"))},getText(){return this.img?"只能上传图片,":this.excel?"只能上传excel文件,":void 0},handleClick(){this.$refs.input.click()},handleChange(e){var t=this.checkFile(e.target.files);if(t&&(this.changed=!1,this.onChange(e.target.files))){for(let t=0;t<e.target.files.length;t++){const i=e.target.files[t];i.input=!0}this.multiple||this.files.splice(0),this.files.push(...e.target.files),this.$refs.input.value=null,this.autoUpload&&t&&this.upload(!1)}},removeFile(e){let t=this.files[e];t.input?this.files.splice(e,1):this.fileInfo.splice(e,1),this.removeBefore(e,t,this.fileInfo)},clearFiles(){this.files.splice(0)},getFiles(){return this.files},upload(e){if(e&&!this.checkFile())return!1;if(!this.url)return this.$message.error("没有配置好Url");if(!this.files||0==this.files.length)return this.$message.error("请选择文件");if(this.uploadBefore(this.files)){var t=new FormData;this.files.forEach((function(e){e.input&&t.append("fileInput",e,e.name)})),this.loadingStatus=!0,this.loadText="上传中..",this.http.post(this.url,t,this.autoUpload?"正在上传文件":"").then(e=>{if(this.loadingStatus=!1,this.loadText="上传文件",!this.uploadAfter(e,this.files))return void(this.changed=!1);if(this.changed=!0,this.$message.success(e.message),this.changed=e.status,!e.status)return;this.fileInfo.splice(0);let t=this.files.map(t=>({name:t.name,path:t.path||e.data+t.name}));this.fileInfo.push(...t),this.files=t},e=>{this.loadText="上传文件",this.loadingStatus=!1})}},format(e,t){const i=e.name.split(".").pop().toLocaleLowerCase()||"";let l="el-icon-document";if(this.fileTypes.length>0&&void 0!=t)return-1!=this.fileTypes.indexOf(i);if(t&&!(t instanceof Array)&&"img"!=t&&"excel"!=t)return t.indexOf(i)>-1;if("img"==t||["gif","jpg","jpeg","png","bmp","webp"].indexOf(i)>-1){if("img"==t)return["gif","jpg","jpeg","png","bmp","webp"].indexOf(i)>-1;l="el-icon-picture-outline"}if(["mp4","m3u8","rmvb","avi","swf","3gp","mkv","flv"].indexOf(i)>-1&&(l="el-icon-document"),["mp3","wav","wma","ogg","aac","flac"].indexOf(i)>-1&&(l="el-icon-document"),["doc","txt","docx","pages","epub","pdf"].indexOf(i)>-1&&(l="el-icon-document"),"excel"==t||["numbers","csv","xls","xlsx"].indexOf(i)>-1){if("excel"==t)return["numbers","csv","xls","xlsx"].indexOf(i)>-1;l="el-icon-document"}return l},beforeUpload(){},checkFile(e){const t=this.files;if(this.multiple&&t.length+(e||[]).length>(this.maxFile||5))return this.$message.error("最多只能选【"+(this.maxFile||5)+"】"+(this.img?"张图片":"个文件")),!1;e||(e=this.files.filter(e=>e.input));let i=[];for(let l=0;l<e.length;l++){const t=e[l];if(-1!=i.indexOf(t.name)&&(t.name="("+l+")"+t.name),i.push(t.name),this.img&&!this.format(t,"img"))return this.$message.error("选择的文件【"+t.name+"】只能是图片格式"),!1;if(this.excel&&!this.format(t,"excel"))return this.$message.error("选择的文件【"+t.name+"】只能是excel文件"),!1;if(this.fileTypes&&this.fileTypes.length>0&&!this.format(t,this.fileTypes))return this.$message.error("选择的文件【"+t.name+"】只能是【"+this.fileTypes.join(",")+"】格式"),!1;if(t.size>1024*(this.maxSize||3)*1024)return this.$message.error("选择的文件【"+t.name+"】不能超过:"+(this.maxSize||3)+"M"),!1}return!0}}},F=(i("73a8"),i("6b0d")),I=i.n(F);const N=I()(w,[["render",C],["__scopeId","data-v-10ef8528"]]);t["default"]=N},"73a8":function(e,t,i){"use strict";i("0604")}}]);