File: /var/www/uileague/cms/js/chunk-52587c48.99a998e4.js
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-52587c48","chunk-2d0cf3a0"],{"638e":function(t,e,n){"use strict";n.r(e),n.d(e,"isEmptyObj",(function(){return c})),n.d(e,"createId",(function(){return u})),n.d(e,"checkIsAnimated",(function(){return l})),n.d(e,"getFileType",(function(){return f}));var i=n("a34a"),r=n.n(i);function a(t,e,n,i,r,a,s){try{var o=t[a](s),c=o.value}catch(u){return void n(u)}o.done?e(c):Promise.resolve(c).then(i,r)}function s(t){return function(){var e=this,n=arguments;return new Promise((function(i,r){var s=t.apply(e,n);function o(t){a(s,i,r,o,c,"next",t)}function c(t){a(s,i,r,o,c,"throw",t)}o(void 0)}))}}var o=[{name:"image/x-icon",mask:[255,255,255,255],byte:[0,0,1,0]},{name:"image/x-icon",mask:[255,255,255,255],byte:[0,0,2,0]},{name:"image/bmp",mask:[255,255],byte:[66,77]},{name:"image/gif",mask:[255,255,255,255,255,255],byte:[71,73,70,56,55,97]},{name:"image/gif",mask:[255,255,255,255,255,255],byte:[71,73,70,56,57,97]},{name:"image/webp",mask:[255,255,255,255,0,0,0,0,255,255,255,255,255,255],byte:[82,73,70,70,0,0,0,0,87,69,66,80,86,80]},{name:"image/png",mask:[255,255,255,255,255,255,255,255],byte:[137,80,78,71,13,10,26,10]},{name:"image/jpeg",mask:[255,255,255],byte:[255,216,255]}];function c(t){return!t||"{}"===JSON.stringify(t)}function u(){return Math.random().toString(36).substring(2)}function l(t){return h.apply(this,arguments)}function h(){return h=s(r.a.mark((function t(e){var n,i,a;return r.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(n=e.file,i=e.fileUrl,a=e.fileType,n&&n instanceof File){t.next=4;break}return console.error("isAnimated param check fail: param expected to be File object"),t.abrupt("return",!1);case 4:if("image/webp"===a||"image/gif"===a){t.next=6;break}return t.abrupt("return",!1);case 6:if("image/webp"!==a){t.next=8;break}return t.abrupt("return",new Promise((function(t){var e=new XMLHttpRequest;e.open("GET",i,!0),e.addEventListener("load",(function(){t(-1!==e.response.indexOf("ANMF"))})),e.send()})));case 8:if("image/gif"!==a){t.next=10;break}return t.abrupt("return",new Promise((function(t){var e=new XMLHttpRequest;e.open("GET",i,!0),e.responseType="arraybuffer",e.addEventListener("load",(function(){var n=new Uint8Array(e.response);if(71===n[0]&&73===n[1]&&70===n[2]&&56===n[3]){for(var i=0,r=0,a=n.length-9;r<a&&i<2;++r)0!==n[r]||33!==n[r+1]||249!==n[r+2]||4!==n[r+3]||0!==n[r+8]||44!==n[r+9]&&33!==n[r+9]||i++;t(i>1)}else t(!1)})),e.send()})));case 10:case"end":return t.stop()}}),t)}))),h.apply(this,arguments)}function f(t){return d.apply(this,arguments)}function d(){return d=s(r.a.mark((function t(e){return r.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(e instanceof File){t.next=2;break}return t.abrupt("return","unknown");case 2:return t.abrupt("return",new Promise((function(t){var n=new FileReader;n.onloadend=function(e){var n=new Uint8Array(e.target.result).slice(0,20),i="unknown",r=o.findIndex((function(t){return t.mask.every((function(e,i){return 0===(e&(n[i]^t.byte[i]))}))}));r>=0&&(i=o[r].name),t(i)},n.readAsArrayBuffer(e)})));case 3:case"end":return t.stop()}}),t)}))),d.apply(this,arguments)}},"8f32":function(t,e,n){},9053:function(t,e,n){"use strict";n.r(e);var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{directives:[{name:"loading",rawName:"v-loading",value:t.loading,expression:"loading"}],staticClass:"upload-imgs-container"},[t._l(t.itemList,(function(e,i){return[e.display?[n("div",{directives:[{name:"loading",rawName:"v-loading",value:e.loading,expression:"item.loading"}],key:e.id,staticClass:"thumb-item",style:t.boxStyle},[n("el-image",{staticClass:"thumb-item-img",staticStyle:{width:"100%",height:"100%"},attrs:{src:e.display,fit:t.fit}}),n("div",{staticClass:"info"},[e.file?n("i",{staticClass:"el-icon-upload wait-upload",attrs:{title:"等待上传"},on:{click:function(n){return n.preventDefault(),n.stopPropagation(),t.delItem(e.id)}}}):t._e()]),n("div",{staticClass:"control"},[t.disabled?t._e():n("i",{staticClass:"el-icon-close del",attrs:{title:"删除"},on:{click:function(n){return n.preventDefault(),n.stopPropagation(),t.delItem(e.id)}}}),t.disabled?t._e():n("div",{staticClass:"preview",attrs:{title:"更换图片"},on:{click:function(n){return n.preventDefault(),n.stopPropagation(),t.handleClick(e.id)}}},[n("i",{staticClass:"el-icon-edit"})]),t.sortable||t.preview?n("div",{staticClass:"control-bottom"},[t.sortable&&!t.disabled?n("i",{staticClass:"control-bottom-btn el-icon-back",class:{disabled:0===i},attrs:{title:"前移"},on:{click:function(n){return n.stopPropagation(),t.move(e.id,-1)}}}):t._e(),t.preview?n("i",{staticClass:"control-bottom-btn el-icon-view",staticStyle:{cursor:"pointer"},attrs:{title:"预览"},on:{click:function(n){return n.stopPropagation(),t.previewImg(e,i)}}}):t._e(),t.sortable&&!t.disabled?n("i",{staticClass:"control-bottom-btn el-icon-right",class:{disabled:i===t.itemList.length-1},attrs:{title:"后移"},on:{click:function(n){return n.stopPropagation(),t.move(e.id,1)}}}):t._e()]):t._e()])],1)]:[n("div",{key:e.id,staticClass:"upload-item",class:{disabled:t.disabled},style:t.boxStyle,on:{click:function(n){return t.handleClick(e.id)},keydown:function(n){return t.handleKeydown(n,e.id)}}},[n("i",{staticClass:"el-icon-plus",staticStyle:{"font-size":"3em"}}),n("div",{staticStyle:{"margin-top":"1em"},domProps:{innerHTML:t._s(t.rulesTip.join("<br>"))}})])]]})),n("input",{ref:"input",staticClass:"upload-imgs__input",attrs:{type:"file",multiple:t.multiple,accept:t.accept},on:{change:t.handleChange}})],2)},r=[],a=n("a34a"),s=n.n(a),o=n("638e");function c(t,e,n,i,r,a,s){try{var o=t[a](s),c=o.value}catch(u){return void n(u)}o.done?e(c):Promise.resolve(c).then(i,r)}function u(t){return function(){var e=this,n=arguments;return new Promise((function(i,r){var a=t.apply(e,n);function s(t){c(a,i,r,s,o,"next",t)}function o(t){c(a,i,r,s,o,"throw",t)}s(void 0)}))}}function l(t){return d(t)||f(t)||h()}function h(){throw new TypeError("Invalid attempt to spread non-iterable instance")}function f(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}function d(t){if(Array.isArray(t)){for(var e=0,n=new Array(t.length);e<t.length;e++)n[e]=t[e];return n}}var m=1024,p=1024*m;function g(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n={loading:!1,id:Object(o["createId"])(),status:"input",src:"",display:"",imgId:""};return t?t.file&&!t.id?(Object(o["isEmptyObj"])(e)?n.status="new":("input"!==e.status&&"new"!==e.status||(n.status="new"),"init"!==e.status&&"edit"!==e.status||(n.status="edit")),n.id=e.id||n.id,n.src="",n.imgId="",n.display=t.localSrc||n.display,n=Object.assign({},t,n),n):(n.id=t.id||Object(o["createId"])(),n.imgId=t.imgId||n.imgId,n.src=t.src||n.src,n.display=t.display||n.display,n.status=t.status||"init",n=Object.assign({},t,n),n):n}function b(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=t;return r+=e&&n?" ".concat(e).concat(i,"~").concat(n).concat(i):e?" ≥ ".concat(e).concat(i):n?" ≤ ".concat(n).concat(i):"无限制",r}var w,v=10,y=[],x={name:"UploadImgs",data:function(){return{itemList:[],loading:!1,currentId:"",globalImgPriview:"$imagePreview"}},props:{width:{type:[Number,String],default:160},height:{type:[Number,String],default:160},autoUpload:{type:Boolean,default:!0},value:{type:Array,default:function(){return[]}},accept:{type:String,default:"image/*"},minNum:{type:Number,default:0},maxNum:{type:Number,default:0},sortable:{type:Boolean,default:!1},preview:{type:Boolean,default:!0},multiple:{type:Boolean,default:!1},rules:{type:[Object,Function],default:function(){return{maxSize:2}}},disabled:{type:Boolean,default:!1},beforeUpload:{type:Function,default:null},remoteFuc:{type:Function,default:null},fit:{type:String,default:"contain"},animatedCheck:{type:Boolean,default:!1}},computed:{boxStyle:function(){var t=this.width,e=this.height,n=this.disabled,i={};"number"===typeof t?i.width="".concat(t,"px"):"string"===typeof t&&(i.width=t),"number"===typeof e?i.height="".concat(e,"px"):"string"===typeof e&&(i.height=e),i.cursor=n?"not-allowed":"pointer";var r=12,a=8;return"number"===typeof t&&t/a<r&&(r=(t/a).toFixed(2)),i.fontSize="".concat(r,"px"),i.textAlign="center",i.position="relative",i.display="flex",i.alignItems="center",i.justifyContent="center",i.overflow="hidden",i.lineHeight="1.3",i.flexDirection="column",i},min:function(){var t=this.minNum;return t<0?0:parseInt(t,10)},max:function(){var t=this.min,e=this.maxNum;return e<t?t:parseInt(e,10)},isStable:function(){var t=this.min,e=this.max;return 0!==e&&t===e},rulesTip:function(){var t,e=this.rules,n=[];if("function"===typeof e)try{t=e()}catch(i){t={}}else t=e||{};return t.width&&t.height?n.push("宽高 ".concat(t.width,"x").concat(t.height)):t.width?(n.push("宽度 ".concat(t.width)),n.push("".concat(b("高度",t.minHeight,t.maxHeight)))):t.height?(n.push("高度 ".concat(t.height)),n.push("".concat(b("宽度",t.minWidth,t.maxWidth)))):(n.push("".concat(b("宽度",t.minWidth,t.maxWidth))),n.push("".concat(b("高度",t.minHeight,t.maxHeight)))),t.ratio&&(Array.isArray(t.ratio)?n.push("宽高比 ".concat(t.ratio.join(":"))):n.push("宽高比 ".concat(t.ratio))),(t.minSize||t.maxSize)&&n.push(b("文件大小",t.minSize,t.maxSize,"Mb")),t.allowAnimated&&t.allowAnimated>0&&(1===t.allowAnimated?n.push("不允许上传动图"):1===t.allowAnimated&&n.push("只允许上传动图")),n}},watch:{value:function(t){this.initItemList(t)}},mounted:function(){this.initItemList(this.value)},methods:{uploadCatch:function(t){var e=this,n={};return t.forEach((function(t,e){n["file_".concat(e)]=t.img.file})),this.$axios({method:"post",url:"/cms/file",data:n}).then((function(e){if(!Array.isArray(e)||0===e.length)throw new Error("图像上传失败");var n=e.reduce((function(t,e){return t[e.key]=e,t}),{});t.forEach((function(t,e){var i=n["file_".concat(e)];t.cb(i)}))})).catch((function(n){t.forEach((function(t){t.cb(!1)}));var i="图像上传失败, 请重试";n.message&&(i=n.message),console.error(n),e.$message.error(i)}))},originUpload:function(t,e){var n=this;if(y.push({img:t,cb:e}),y.length===v){var i=l(y);return y=[],clearTimeout(w),w=null,this.uploadCatch(i)}w&&y.length<v&&clearTimeout(w),w=setTimeout((function(){n.uploadCatch(l(y)),y=[],w=null}),50)},uploadImg:function(){var t=u(s.a.mark((function t(e){var n,i,r,a=this;return s.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(n=function(t,e){t.loading=!1,e&&(t.display=e.url,t.src=e.path,t.imgId=e.id,t.file=null,window.URL.revokeObjectURL(t.display))},"input"!==e.status&&e.file){t.next=3;break}return t.abrupt("return");case 3:if(e.loading=!0,!this.beforeUpload||"function"!==typeof this.beforeUpload){t.next=12;break}if("function"!==typeof this.beforeUpload){t.next=12;break}return t.next=8,new Promise((function(t){var n;try{n=a.beforeUpload(e,(function(e){t(!!e)}))}catch(i){t(!1)}null!=n&&"function"===typeof n.then&&n.then((function(e){t(!!e)})).catch((function(){t(!1)}))}));case 8:if(i=t.sent,i){t.next=12;break}return n(e,!1),t.abrupt("return",!1);case 12:if(!this.remoteFuc||"function"!==typeof this.remoteFuc){t.next=20;break}return t.next=15,new Promise((function(t){var n;try{n=a.remoteFuc(e.file,(function(e){t(e||!1)}))}catch(i){a.$message.error("执行自定义上传出错"),t(!1)}null!=n&&"function"===typeof n.then&&n.then((function(e){t(e||!1)})).catch((function(){t(!1)}))}));case 15:if(r=t.sent,n(e,r),r){t.next=19;break}return t.abrupt("return",!1);case 19:return t.abrupt("return",e);case 20:return t.abrupt("return",new Promise((function(t){a.originUpload(e,(function(i){n(e,i),t(!!i&&e)}))})));case 21:case"end":return t.stop()}}),t,this)})));function e(e){return t.apply(this,arguments)}return e}(),getValue:function(){var t=u(s.a.mark((function t(){var e,n,i,r,a,o,c,u,l;return s.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:e=this.itemList,n=this.isStable,i=this.min,r=n?e.length:e.length-1,a=0;case 3:if(!(a<r)){t.next=10;break}if("input"!==e[a].status){t.next=7;break}return this.$message.error("当前存在未选择图片, 请全部选择"),t.abrupt("return",!1);case 7:a+=1,t.next=3;break;case 10:if(!(r<i)){t.next=13;break}return this.$message.error("至少选择".concat(i,"张图片")),t.abrupt("return",!1);case 13:for(o=[],c=0;c<e.length;c+=1)"input"!==e[c].status&&(e[c].file?o.push(this.uploadImg(e[c])):o.push(Promise.resolve(e[c])));return t.next=17,Promise.all(o);case 17:if(u=t.sent,!u.some((function(t){return!t}))){t.next=20;break}return t.abrupt("return",!1);case 20:return l=u.map((function(t){var e={id:"new"===t.status?"":t.id,imgId:t.imgId||null,src:t.src||null,display:t.display,width:t.width||null,height:t.height||null,fileSize:t.size||null,fileName:t.name||null,fileType:t.type||null,isAnimated:t.isAnimated||null};return e})),this.$emit("upload",l),t.abrupt("return",l);case 23:case"end":return t.stop()}}),t,this)})));function e(){return t.apply(this,arguments)}return e}(),delItem:function(t){var e=this.itemList,n=this.isStable,i=e.findIndex((function(e){return e.id===t})),r=e[i].display;n?(e[i]=g(),this.itemList=l(e)):e.splice(i,1),window.URL.revokeObjectURL(r),this.initItemList(this.itemList)},previewImg:function(t,e){if(this[this.globalImgPriview]){var n=[];this.itemList.forEach((function(t){t.display&&n.push(t.display)})),this[this.globalImgPriview]({images:n,index:e})}else this.$confirm('<img src="'.concat(t.display,'" style="width: 100%;" />'),"预览",{dangerouslyUseHTMLString:!0})},move:function(t,e){var n=this.itemList,i=this.isStable,r=n.findIndex((function(e){return e.id===t}));if(!(r+e<0||r+e>=n.length)&&(i||r+e!==n.length-1||"input"!==n[n.length-1].status)){var a=n[r],s=n[r+e];n[r]=s,n[r+e]=a,this.itemList=l(n)}},validateImg:function(){var t=u(s.a.mark((function t(e){var n,i,r;return s.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(n=this.rules,"function"===typeof n)try{i=n(e)}catch(a){i={}}else i=n;if(!(i.allowAnimated&&i.allowAnimated>0)){t.next=11;break}if(null!==e.isAnimated){t.next=7;break}this.$message.error('要进行是否动图验证需要配置 "animated-check" 属性为 true'),t.next=11;break;case 7:if(1!==i.allowAnimated||!e.isAnimated){t.next=9;break}throw new Error('"'.concat(e.name,'"为动态图, 不允许上传'));case 9:if(2!==i.allowAnimated||e.isAnimated){t.next=11;break}throw new Error('"'.concat(e.name,'"为静态图, 只允许上传动态图'));case 11:if(!i.width){t.next=16;break}if(e.width===i.width){t.next=14;break}throw new Error('"'.concat(e.name,'"图像宽不符合要求, 需为').concat(i.width));case 14:t.next=20;break;case 16:if(!(i.minWidth&&e.width<i.minWidth)){t.next=18;break}throw new Error('"'.concat(e.name,'"图像宽不符合要求, 至少为').concat(i.minWidth));case 18:if(!(i.maxWidth&&e.width>i.maxWidth)){t.next=20;break}throw new Error('"'.concat(e.name,'"图像宽不符合要求, 至多为').concat(i.maxWidth));case 20:if(!i.height){t.next=25;break}if(e.height===i.height){t.next=23;break}throw new Error('"'.concat(e.name,'"图像高不符合要求, 需为').concat(i.height));case 23:t.next=29;break;case 25:if(!(i.minHeight&&e.height<i.minHeight)){t.next=27;break}throw new Error('"'.concat(e.name,'"图像高不符合要求, 至少为').concat(i.minHeight));case 27:if(!(i.maxHeight&&e.height>i.maxHeight)){t.next=29;break}throw new Error('"'.concat(e.name,'"图像高不符合要求, 至多为').concat(i.maxHeight));case 29:if(!i.ratio){t.next=34;break}if(r=Array.isArray(i.ratio)?i.ratio[0]/i.ratio[1]:i.ratio,r=r.toFixed(2),(e.width/e.height).toFixed(2)===r){t.next=34;break}throw new Error('"'.concat(e.name,'"图像宽高比不符合要求, 需为').concat(r));case 34:if(!(i.minSize&&e.size<i.minSize*p)){t.next=36;break}throw new Error('"'.concat(e.name,'"图像文件大小比不符合要求, 至少为').concat(i.minSize,"Mb"));case 36:if(!(i.maxSize&&e.size>i.maxSize*p)){t.next=38;break}throw new Error('"'.concat(e.name,'"图像文件大小比不符合要求, 至多为').concat(i.maxSize,"Mb"));case 38:return t.abrupt("return",!0);case 39:case"end":return t.stop()}}),t,this)})));function e(e){return t.apply(this,arguments)}return e}(),handleChange:function(){var t=u(s.a.mark((function t(e){var n,i,r,a,o,c,l,h,f,d=this;return s.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:if(n=this.currentId,i=this.autoUpload,r=e.target.files,r){t.next=4;break}return t.abrupt("return");case 4:for(o=[],c=function(){var t=u(s.a.mark((function t(e){var n;return s.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,d.getImgInfo(e);case 3:return n=t.sent,o.push(n),t.next=7,d.validateImg(n);case 7:return t.abrupt("return",n);case 10:throw t.prev=10,t.t0=t["catch"](0),t.t0;case 13:case"end":return t.stop()}}),t,null,[[0,10]])})));return function(e){return t.apply(this,arguments)}}(),l=[],h=0;h<r.length;h+=1)l.push(c(r[h]));return t.prev=8,t.next=11,Promise.all(l);case 11:a=t.sent,this.setImgInfo(a,n),i&&this.itemList.forEach((function(t){d.uploadImg(t)})),t.next=22;break;case 16:for(t.prev=16,t.t0=t["catch"](8),f=0;f<o.length;f+=1)window.URL.revokeObjectURL(o[f].localSrc);o=null,console.error(t.t0),this.$message.error(t.t0.message);case 22:case"end":return t.stop()}}),t,this,[[8,16]])})));function e(e){return t.apply(this,arguments)}return e}(),setImgInfo:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0,n=this.max,i=this.itemList,r=this.itemList.findIndex((function(t){return t.id===e}));if(window.URL.revokeObjectURL(this.itemList[r].display),this.itemList[r]=g(t[0],this.itemList[r]),t.length>1){var a=t.length;if(this.isStable)for(var s=0,o=1;s<n&&o<a;s+=1)"input"===i[s].status&&(this.itemList[s]=g(t[o]),o+=1);else{var c=n-i.length;n&&a>c&&(a=c),"input"===i[i.length-1].status&&this.itemList.pop();for(var u=1;u<=a;u+=1)this.itemList.push(g(t[u]))}}this.initItemList(this.itemList)},handleKeydown:function(t,e){t.target===t.currentTarget&&(13!==t.keyCode&&32!==t.keyCode||this.handleClick(e))},handleClick:function(t){this.disabled||(this.currentId=t||"",this.$refs.input.value=null,this.$refs.input.click())},initItemList:function(t){var e=this.max,n=this.isStable,i=this.disabled,r=[];if(!t||!Array.isArray(t)||0===t.length){if(n){for(var a=0;a<e;a+=1)r.push(g());return void(this.itemList=r)}return r.push(g()),void(this.itemList=r)}for(var s=0;s<t.length;s+=1)r.push(g(t[s]));(0===e||t.length<e)&&!i&&"input"!==t[t.length-1].status&&r.push(g()),this.itemList=r},getImgInfo:function(){var t=u(s.a.mark((function t(e){var n,i,r,a;return s.a.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return n=this.animatedCheck,i=window.URL.createObjectURL(e),t.next=4,Object(o["getFileType"])(e);case 4:if(r=t.sent,a=null,!n){t.next=10;break}return t.next=9,Object(o["checkIsAnimated"])({file:e,fileType:r,fileUrl:i});case 9:a=t.sent;case 10:return t.abrupt("return",new Promise((function(t,n){var s=new Image;s.src=i,s.onload=function(){var n={localSrc:i,file:e,width:s.width,height:s.height,name:e.name,size:e.size,type:"unknow"===r?e.type:r,lastModified:e.lastModified,isAnimated:a};t(n),s=null},s.onerror=function(){n(new Error("图像加载失败")),s=null}})));case 11:case"end":return t.stop()}}),t,this)})));function e(e){return t.apply(this,arguments)}return e}(),clear:function(){this.initItemList([]),this.getValue()},reset:function(){this.initItemList(this.value)}}},k=x,I=(n("daba0"),n("2877")),L=Object(I["a"])(k,i,r,!1,null,"18ca712f",null);e["default"]=L.exports},daba0:function(t,e,n){"use strict";var i=n("8f32"),r=n.n(i);r.a}}]);