wangxinhui
2024-12-26 78b99e5348592a29ca1393a5e13db619cc4eba56
1
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-1ad6b75a"],{"14cf":function(e,t,l){"use strict";l.r(t);var i=l("7a23");const s=e=>(Object(i["pushScopeId"])("data-v-10ef8528"),e=e(),Object(i["popScopeId"])(),e),a={class:"upload-container"},n={class:"input-btns",style:{"margin-bottom":"10px"}},o=["multiple"],c={key:0,class:"upload-img"},r={class:"operation"},d={class:"action"},p=["onClick"],h=["onClick"],m=s(()=>Object(i["createElementVNode"])("div",{class:"mask"},null,-1)),f=["src","onerror"],u=s(()=>Object(i["createElementVNode"])("i",{class:"el-icon-camera-solid"},null,-1)),g=[u],b={key:0},O={key:1},j={class:"upload-list"},k=["onClick"],v=["onClick"],x=s(()=>Object(i["createElementVNode"])("i",{class:"el-icon-close"},null,-1)),y=[x];function C(e,t,l,s,u,x){const C=Object(i["resolveComponent"])("el-button"),B=Object(i["resolveComponent"])("el-alert");return Object(i["openBlock"])(),Object(i["createElementBlock"])("div",a,[Object(i["createElementVNode"])("div",null,[Object(i["createElementVNode"])("div",n,[Object(i["createElementVNode"])("input",{ref:"input",type:"file",style:{display:"none"},onChange:t[0]||(t[0]=(...e)=>x.handleChange&&x.handleChange(...e)),multiple:l.multiple},null,40,o),l.img?(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",c,[(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(u.files,(e,t)=>(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",{key:t,class:"img-item"},[Object(i["createElementVNode"])("div",r,[Object(i["createElementVNode"])("div",d,[Object(i["createElementVNode"])("i",{class:"el-icon-view view",onClick:e=>x.previewImg(t)},null,8,p),Object(i["createElementVNode"])("i",{class:"el-icon-delete remove",onClick:e=>x.removeFile(t)},null,8,h)]),m]),Object(i["createElementVNode"])("img",{src:x.getImgSrc(e,t),onerror:u.errorImg},null,8,f)]))),128)),Object(i["withDirectives"])(Object(i["createElementVNode"])("div",{class:Object(i["normalizeClass"])(["img-selector",x.getSelector()])},[Object(i["createElementVNode"])("div",{class:"selector",onClick:t[1]||(t[1]=(...e)=>x.handleClick&&x.handleClick(...e))},g),l.autoUpload?Object(i["createCommentVNode"])("",!0):(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",{key:0,class:Object(i["normalizeClass"])(["s-btn",{readonly:u.changed}]),onClick:t[2]||(t[2]=(...e)=>x.upload&&x.upload(...e))},[Object(i["createElementVNode"])("div",null,Object(i["toDisplayString"])(u.loadText),1)],2))],2),[[i["vShow"],!l.autoUpload||l.autoUpload&&u.files.length<l.maxFile]])])):(Object(i["openBlock"])(),Object(i["createBlock"])(C,{key:1,onClick:x.handleClick},{default:Object(i["withCtx"])(()=>[Object(i["createTextVNode"])("选择"+Object(i["toDisplayString"])(l.img?"图片":"文件"),1)]),_:1},8,["onClick"])),l.autoUpload||l.img?Object(i["createCommentVNode"])("",!0):(Object(i["openBlock"])(),Object(i["createBlock"])(C,{key:2,type:"info",disabled:u.changed,onClick:t[3]||(t[3]=e=>x.upload(!0)),loading:u.loadingStatus},{default:Object(i["withCtx"])(()=>[Object(i["createTextVNode"])("上传文件")]),_:1},8,["disabled","loading"]))]),Object(i["renderSlot"])(e.$slots,"default",{},void 0,!0),l.desc?(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",b,[Object(i["createVNode"])(B,{title:x.getText()+"文件大小不超过"+(l.maxSize||3)+"M",type:"info","show-icon":""},null,8,["title"])])):Object(i["createCommentVNode"])("",!0),Object(i["renderSlot"])(e.$slots,"content",{},void 0,!0),l.img?Object(i["createCommentVNode"])("",!0):(Object(i["openBlock"])(),Object(i["createElementBlock"])("div",O,[Object(i["withDirectives"])(Object(i["createElementVNode"])("ul",j,[(Object(i["openBlock"])(!0),Object(i["createElementBlock"])(i["Fragment"],null,Object(i["renderList"])(u.files,(e,t)=>(Object(i["openBlock"])(),Object(i["createElementBlock"])("li",{class:"list-file",key:t},[Object(i["createElementVNode"])("a",null,[Object(i["createElementVNode"])("span",{onClick:l=>x.fileOnClick(t,e)},[Object(i["createElementVNode"])("i",{class:Object(i["normalizeClass"])(x.format(e))},null,2),Object(i["createTextVNode"])(" "+Object(i["toDisplayString"])(e.name),1)],8,k)]),Object(i["createElementVNode"])("span",{onClick:e=>x.removeFile(t),class:"file-remove"},y,8,v)]))),128))],512),[[i["vShow"],l.fileList]])])),Object(i["renderSlot"])(e.$slots,"tip",{},void 0,!0)])])}l("88a7"),l("271a"),l("5494"),l("14d9");var B={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,l)=>!0},removeBefore:{type:Function,default:(e,t,l)=>!0},append:{type:Boolean,default:!1},compress:{type:Boolean,default:!1}},data(){return{errorImg:'this.src="'+l("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 l=e.target.files[t];l.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 l=e.name.split(".").pop().toLocaleLowerCase()||"";let i="el-icon-document";if(this.fileTypes.length>0&&void 0!=t)return-1!=this.fileTypes.indexOf(l);if(t&&!(t instanceof Array)&&"img"!=t&&"excel"!=t)return t.indexOf(l)>-1;if("img"==t||["gif","jpg","jpeg","png","bmp","webp"].indexOf(l)>-1){if("img"==t)return["gif","jpg","jpeg","png","bmp","webp"].indexOf(l)>-1;i="el-icon-picture-outline"}if(["mp4","m3u8","rmvb","avi","swf","3gp","mkv","flv"].indexOf(l)>-1&&(i="el-icon-document"),["mp3","wav","wma","ogg","aac","flac"].indexOf(l)>-1&&(i="el-icon-document"),["doc","txt","docx","pages","epub","pdf"].indexOf(l)>-1&&(i="el-icon-document"),"excel"==t||["numbers","csv","xls","xlsx"].indexOf(l)>-1){if("excel"==t)return["numbers","csv","xls","xlsx"].indexOf(l)>-1;i="el-icon-document"}return i},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 l=[];for(let i=0;i<e.length;i++){const t=e[i];if(-1!=l.indexOf(t.name)&&(t.name="("+i+")"+t.name),l.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}}},w=(l("73a8"),l("d959")),N=l.n(w);const E=N()(B,[["render",C],["__scopeId","data-v-10ef8528"]]);t["default"]=E},"56cd":function(e,t,l){},"73a8":function(e,t,l){"use strict";l("56cd")}}]);