chunk-192c303f.f742ed4a.js 19 KB

1
  1. (window.webpackJsonp=window.webpackJsonp||[]).push([["chunk-192c303f"],{"2b83":function(t,e,i){},"44cd":function(t,e,i){"use strict";var a=i("2b83");i.n(a).a},8084:function(t,e,i){"use strict";i.r(e);var a=i("a34a"),s=i.n(a),n=i("12e0"),r=i("d708"),o=i("c276"),c=i("7774"),l=i("40cb");function u(t,e){var i=Object.keys(t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(t);e&&(a=a.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),i.push.apply(i,a)}return i}function d(t){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?u(i,!0).forEach((function(e){p(t,e,i[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(i)):u(i).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(i,e))}))}return t}function p(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function h(t){return function(t){if(Array.isArray(t)){for(var e=0,i=new Array(t.length);e<t.length;e++)i[e]=t[e];return i}}(t)||function(t){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t))return Array.from(t)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function f(t,e,i,a,s,n,r){try{var o=t[n](r),c=o.value}catch(t){return void i(t)}o.done?e(c):Promise.resolve(c).then(a,s)}function m(t){return function(){var e=this,i=arguments;return new Promise((function(a,s){var n=t.apply(e,i);function r(t){f(n,a,s,r,o,"next",t)}function o(t){f(n,a,s,r,o,"throw",t)}r(void 0)}))}}var g={name:"uploadPictures",components:{uploadVideo:c.default,uploadImg:l.a},props:{isChoice:{type:String,default:""},gridBtn:{type:Object,default:null},gridPic:{type:Object,default:null},isShow:{type:Number,default:1}},data:function(){return{searchClass:!1,spinShow:!1,fileUrl:r.a.apiBaseURL+"/file/upload",modalPic:!1,treeData:[],treeData2:[],pictrueList:[],uploadData:{},checkPicList:[],uploadName:{name:"",file_type:"1"},FromData:null,treeId:0,isJudge:!1,buttonProps:{type:"default",size:"small"},fileData:{pid:0,page:1,limit:24},total:0,pids:0,list:[],modalTitleSs:"",isShowPic:!1,header:{},ids:[],headTab:[{title:"图片",name:"1"},{title:"视频",name:"2"}],modalVideo:!1,uploadVisible:!1,layout:1,columns4:[{type:"selection",width:60,align:"center"},{title:"图片名称",slot:"poster"},{title:"大小",key:"att_size"},{title:"上传时间",key:"time"},{title:"操作",slot:"action",width:150}],cascaderData:[]}},mounted:function(){var t=this,e=this.$refs.main,i=Math.floor((e.clientWidth-40)/165),a=Math.ceil(24/i);this.fileData.limit=i*a,this.getToken(),this.getList(),this.getFileList(),document.addEventListener("click",(function(e){e.target.classList.contains("nameStyle")||e.target.classList.contains("preview")||e.target.classList.contains("ivu-icon-ios-eye")||e.target.parentNode.classList.contains("nameStyle")||(t.player&&(t.player.dispose(),t.player=null),t.pictrueList.forEach((function(t){t.realName=!1})))}),!0)},methods:{createPoster:function(t){new Promise((function(e,i){var a=document.createElement("video");a.setAttribute("src",t.att_dir),a.setAttribute("crossOrigin","anonymous"),a.setAttribute("width",100),a.setAttribute("height",100),a.setAttribute("preload","auto"),a.addEventListener("canplay",(function(){var t=document.createElement("canvas"),i=t.getContext("2d"),s=a.width,n=a.height;t.width=s,t.height=n,i.drawImage(a,0,0,s,n),e(t.toDataURL("image/jpeg"))}))})).then((function(e){t.poster=e}))},preview:function(t){if(2==this.pictrueList[t].file_type&&this.createPlayer(this.pictrueList[t]),1===this.layout){if(!this.pictrueList[t].realName)for(var e=0;e<this.pictrueList.length;e++)this.pictrueList[e].realName=!1;this.pictrueList[t].realName=!this.pictrueList[t].realName}2===this.layout&&this.$refs["sattDir".concat(t)].$viewer.show()},rename:function(t){var e=this;this.$Modal.confirm({render:function(i){return i("Input",{props:{value:e.pictrueList[t].editName,autofocus:!0,placeholder:"请输入文件名"},on:{input:function(i){e.pictrueList[t].real_name=i}}})},onOk:function(){e.bindTxt(e.pictrueList[t])}})},createPlayer:function(t){this.player&&(this.player.dispose(),this.player=null),this.player=new Aliplayer({id:"player".concat(t.att_id),width:"100%",height:"100%",autoplay:!0,source:t.att_dir})},uploadVideo:function(){this.modalVideo=!0},getvideo:function(){this.modalVideo=!1,this.fileData.page=1,this.getFileList()},onhangeTab:function(){this.getList(),this.getFileList(),this.checkPicList=[]},enterMouse:function(t){t.realName=!t.realName},enterLeave:function(t){t.isShowEdit=!t.isShowEdit},getToken:function(){this.header["Authori-zation"]="Bearer "+o.a.cookies.get("token")},renderContent:function(t,e){var i=this,a=e.root,s=e.node,n=e.data,r=[];return 0==n.pid&&r.push(t("DropdownItem",{props:{name:"1"}},"添加")),n.id&&r.push(t("DropdownItem",{props:{name:"2"}},"编辑"),t("DropdownItem",{props:{name:"3"}},"删除")),t("span",{style:{position:"relative",display:"inline-block",width:"100%"},attrs:{id:"tree"+n.id},on:{mouseover:function(){n.flag=!0,i.$refs.tree.$el.querySelector("#tree".concat(n.id)).parentNode.parentNode.classList.add("hovering")},mouseout:function(){n.flag=!1,i.$refs.tree.$el.querySelector("#tree".concat(n.id)).parentNode.parentNode.classList.remove("hovering")},click:function(){i.appendBtn(a,s,n)}}},[t("span",{on:{}},[t("Icon",{props:{type:"ios-folder-outline"},style:{marginRight:"8px",visibility:n.pid?"hidden":"visible"}}),t("span",n.title)]),t("Dropdown",{style:{position:"absolute",top:0,right:0},on:{"on-click":function(t){switch(t){case"1":i.append(a,s,n);break;case"2":i.editPic(a,s,n);break;case"3":i.remove(a,s,n,"分类")}}}},[t("Icon",{props:{type:"ios-more"},style:{display:n.flag?"inline-block":"none",marginRight:"8px",fontSize:"20px"}}),t("DropdownMenu",{slot:"list"},r)])])},renderContentSel:function(t,e){var i=this,a=e.root,s=e.node,n=e.data;return t("div",{style:{display:"inline-block",width:"90%"}},[t("span",[t("span",{style:{cursor:"pointer"},class:["ivu-tree-title"],on:{click:function(t){i.handleCheckChange(a,s,n,t)}}},n.title)])])},handleCheckChange:function(t,e,i,a){this.list=[];var s=i.id,n=i.title;this.list.push({value:s,title:n}),this.ids.length?(this.pids=s,this.getMove()):this.$Message.warning("请先选择图片");for(var r=this.$refs.reference.$el.querySelectorAll(".ivu-tree-title-selected"),o=0;o<r.length;o++)r[o].className="ivu-tree-title";a.path[0].className="ivu-tree-title ivu-tree-title-selected"},getMove:function(){var t=this,e={pid:this.pids,images:this.ids.toString()};Object(n.g)(e).then(function(){var e=m(s.a.mark((function e(i){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t.$Message.success(i.msg),t.getFileList(),t.pids=0,t.checkPicList=[],t.ids=[];case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){t.$Message.error(e.msg)}))},editPicList:function(t){var e=this,i={ids:this.ids.toString()};"number"==typeof t&&(i={ids:t.toString()});var a={title:1==this.uploadName.file_type?"删除选中图片":"删除选中视频",url:"file/file/delete",method:"POST",ids:i};this.$modalSure(a).then((function(t){e.$Message.success(t.msg),e.getFileList(),e.checkPicList=[]})).catch((function(t){e.$Message.error(t.msg)}))},onMouseOver:function(t,e,i){event.preventDefault(),i.flag=!i.flag},onClick:function(t,e,i){i.flag2=!i.flag2},appendBtn:function(t,e,i){var a=this.$refs.tree.$el,s=i.id||0;if(this.treeId===s)return!1;a.querySelector(".selected").classList.remove("selected"),a.querySelector("#tree".concat(i.id)).parentNode.parentNode.classList.add("selected"),this.treeId=s,this.fileData.page=1,this.getFileList()},append:function(t,e,i){this.treeId=i.id,this.getFrom()},remove:function(t,e,i,a){var s=this;this.tits=a;var n={title:"删除 [ "+i.title+" ] 分类",url:"file/category/".concat(i.id),method:"DELETE",ids:""};this.$modalSure(n).then((function(t){s.$Message.success(t.msg),s.getList(),s.checkPicList=[]})).catch((function(t){s.$Message.error(t.msg)}))},editPic:function(t,e,i){var a=this;this.$modalForm(Object(n.a)(i.id,{file_type:this.uploadName.file_type})).then((function(){return a.getList()}))},changePage:function(){this.fileData.page=1,this.getFileList(),this.checkPicList=[]},getList:function(t){var e=this,i={title:1==this.uploadName.file_type?"全部图片":"全部视频",id:"",pid:0};Object(n.f)(this.uploadName).then(function(){var a=m(s.a.mark((function a(n){var r,o;return s.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:r=n.data.list,(o=[i].concat(h(r))).forEach((function(t,e){t.flag=!1,t.selected=!e,t.label=t.title,t.value=t.id})),e.treeData=o,e.$nextTick((function(){e.$refs.tree.$el.querySelector("#tree".concat(o[0].id)).parentNode.parentNode.classList.add("selected")})),e.cascaderData=JSON.parse(JSON.stringify(o)),e.cascaderData.shift(),"search"!==t?e.treeData2=h(e.treeData):e.searchClass=!0,e.addFlag(e.treeData);case 9:case"end":return a.stop()}}),a)})));return function(t){return a.apply(this,arguments)}}()).catch((function(t){e.$Message.error(t.msg)}))},loadData:function(t,e){t.loading=!0,Object(n.f)({pid:t.id,file_type:this.uploadName.file_type}).then(function(){var i=m(s.a.mark((function i(a){var n,r;return s.a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:n=a.data.list,r=n.map((function(t){return d({},t,{label:t.title,value:t.id,flag:!1})})),t.loading=!1,Object.hasOwnProperty.call(t,"nodeKey")?e(r):(t.children=r,e());case 4:case"end":return i.stop()}}),i)})));return function(t){return i.apply(this,arguments)}}()).catch((function(t){}))},addFlag:function(t){var e=this;t.map((function(t){e.$set(t,"flag",!1),e.$set(t,"flag2",!1),t.children&&e.addFlag(t.children)}))},add:function(){this.treeId=0,this.getFrom()},getFileList:function(){var t=this;this.fileData.pid=this.treeId,this.fileData.file_type=this.uploadName.file_type,this.fileData.name=this.uploadName.name,Object(n.d)(this.fileData).then(function(){var e=m(s.a.mark((function e(i){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:i.data.list.forEach((function(e){e._checked=!1,e.isSelect=!1,e.isEdit=!1,e.isShowEdit=!1,e.realName=!1,e.num=0,t.editName(e),2==e.file_type&&(e.poster="",e.satt_dir.includes("uploads")&&t.createPoster(e))})),t.pictrueList=i.data.list,t.pictrueList.length?t.isShowPic=!1:t.isShowPic=!0,t.total=i.data.count;case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()).catch((function(e){t.$Message.error(e.msg)}))},pageChange:function(t){this.fileData.page=t,this.getFileList(),this.checkPicList=[]},getFrom:function(){var t=this;this.$modalForm(Object(n.b)({id:this.treeId,file_type:this.uploadName.file_type})).then((function(e){t.getList()}))},beforeUpload:function(t){var e=this;if(-1===["image/png","image/jpg","image/jpeg","image/gif"].indexOf(t.type))return this.$Message.warning({content:"文件 "+t.name+" 格式不正确, 请选择格式正确的图片",duration:5}),!1;var i=this.$cache.local.getJSON("file_size_max"),a=i/1024/1024;return t.size<i?(this.uploadData={pid:this.treeId},new Promise((function(t){e.$nextTick((function(){t(!0)}))}))):(this.$Message.warning({content:"文件体积过大,图片大小不能超过"+a+"M",duration:5}),!1)},handleSuccess:function(t,e,i){200===t.status?(this.fileData.page=1,this.$Message.success(t.msg),this.getFileList()):this.$Message.error(t.msg)},cancel:function(){this.$emit("changeCancel")},selectionChange:function(t){for(var e=0;e<this.pictrueList.length;e++){this.pictrueList[e].isSelect=this.pictrueList[e]._checked=!1,this.pictrueList[e].num=0;for(var i=0;i<t.length;i++)if(this.pictrueList[e].att_id===t[i].att_id){this.pictrueList[e].isSelect=this.pictrueList[e]._checked=!0,this.pictrueList[e].num=i+1;break}}this.checkPicList=t,this.ids=this.checkPicList.map((function(t){return t.att_id}))},changImage:function(t,e,i){var a=this;t.isSelect=!t.isSelect,t._checked=t.isSelect,this.checkPicList=this.pictrueList.filter((function(t){return t.isSelect})),this.ids=[],this.checkPicList.map((function(t,e){a.ids.push(t.att_id)})),this.pictrueList.map((function(t,e){t.isSelect?a.checkPicList.filter((function(e,i){t.att_id==e.att_id&&(t.num=i+1)})):t.num=0}))},checkPics:function(){if("单选"===this.isChoice){if(this.checkPicList.length>1)return this.$Message.warning("最多只能选一张图片");this.$emit("getPic",this.checkPicList[0])}else{var t=this.$route.query.maxLength;if(void 0!=t&&this.checkPicList.length>Number(t))return this.$Message.warning("最多只能选"+t+"张图片");this.$emit("getPicD",this.checkPicList)}},editName:function(t){var e=t.real_name.split("."),i=void 0==e[1]?[]:e[1];e[0].length,i.length,t.editName=t.real_name},bindTxt:function(t){var e=this;""==t.real_name&&this.$Message.error("请填写内容"),Object(n.e)(t.att_id,{real_name:t.real_name}).then((function(i){e.editName(t),t.isEdit=!1,e.$Message.success(i.msg)})).catch((function(t){e.$Message.error(t.msg)}))},openUpload:function(){this.uploadVisible=!0},uploadSuccess:function(){this.uploadVisible=!1,this.fileData.page=1,this.getFileList()}}},v=(i("44cd"),i("2877")),y=Object(v.a)(g,(function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{staticClass:"Modal"},[i("Row",[i("Col",{attrs:{span:"24"}},[i("Tabs",{on:{"on-click":t.onhangeTab},model:{value:t.uploadName.file_type,callback:function(e){t.$set(t.uploadName,"file_type",e)},expression:"uploadName.file_type"}},t._l(t.headTab,(function(t,e){return i("TabPane",{key:e,attrs:{label:t.title,name:t.name}})})),1)],1)],1),i("Row",{staticStyle:{display:"none"}},[i("Col",{attrs:{span:"5"}},[i("div",{staticClass:"input"},[i("Input",{staticStyle:{width:"90%"},attrs:{search:"",placeholder:"请输入分类名称"},on:{"on-search":t.changePage},model:{value:t.uploadName.name,callback:function(e){t.$set(t.uploadName,"name",e)},expression:"uploadName.name"}})],1)]),i("Col",{attrs:{span:"20"}},[1==t.uploadName.file_type?i("Button",{staticClass:"mr10",on:{click:t.openUpload}},[t._v("上传图片")]):i("Button",{staticClass:"mr10",on:{click:t.uploadVideo}},[t._v("上传视频")]),i("Button",{staticClass:"mr10",attrs:{disabled:0===t.checkPicList.length},on:{click:function(e){return e.stopPropagation(),t.editPicList("图片")}}},[t._v(t._s(1==t.uploadName.file_type?"删除图片":"删除视频"))])],1)],1),i("Row",{attrs:{type:"flex",justify:"start"}},[i("Col",{attrs:{span:"4"}},[i("div",{staticClass:"trees"},[i("Tree",{ref:"tree",staticClass:"treeBox",attrs:{data:t.treeData,render:t.renderContent,"load-data":t.loadData}}),t.searchClass&&t.treeData.length<=1?i("div",{staticClass:"searchNo"},[t._v("\r\n 此分类暂无数据\r\n ")]):t._e()],1)]),i("Col",{attrs:{span:"19"}},[i("div",{staticClass:"right-container"},[i("div",{staticClass:"header"},[i("div",[1==t.uploadName.file_type?i("Button",{staticClass:"mr10 upload",on:{click:t.openUpload}},[t._v("上传图片")]):i("Button",{staticClass:"mr10 upload",on:{click:t.uploadVideo}},[t._v("上传视频")]),i("Button",{staticClass:"mr10",attrs:{disabled:0===t.checkPicList.length},on:{click:function(e){return e.stopPropagation(),t.editPicList("图片")}}},[t._v(t._s(1==t.uploadName.file_type?"删除图片":"删除视频"))]),i("div",{staticClass:"select-wrapper"},[i("Cascader",{attrs:{data:t.cascaderData,"load-data":t.loadData,"change-on-select":""}})],1)],1),i("div",[i("div",{staticClass:"input-wrapper"},[i("Input",{attrs:{search:"",placeholder:"搜索图片名称"},on:{"on-search":t.changePage},model:{value:t.uploadName.name,callback:function(e){t.$set(t.uploadName,"name",e)},expression:"uploadName.name"}})],1),i("RadioGroup",{attrs:{type:"button","button-style":"solid"},model:{value:t.layout,callback:function(e){t.layout=e},expression:"layout"}},[i("Radio",{attrs:{label:1}},[i("Icon",{attrs:{custom:"iconfont icongongge",size:"14"}})],1),i("Radio",{attrs:{label:2}},[i("Icon",{attrs:{custom:"iconfont iconliebiao",size:"14"}})],1)],1)],1)]),i("div",{ref:"main",staticClass:"main"},[i("div",{directives:[{name:"show",rawName:"v-show",value:t.isShowPic&&1==t.layout,expression:"isShowPic && layout == 1"}],staticClass:"imagesNo"},[i("Icon",{attrs:{type:"ios-images",size:"60",color:"#dbdbdb"}}),i("span",{staticClass:"imagesNo_sp"},[t._v(t._s(1==t.uploadName.file_type?"图片库为空":"视频库为空"))])],1),i("transition",[1==t.layout?i("div",{key:"grid",staticClass:"acea-row conter"},t._l(t.pictrueList,(function(e,a){return i("div",{key:a,staticClass:"pictrueList_pic",on:{mouseenter:function(i){return t.enterLeave(e)},mouseleave:function(i){return t.enterLeave(e)}}},[e.num>0?i("p",{staticClass:"number"},[i("Badge",{attrs:{count:e.num,type:"error",offset:[11,12]}},[i("a",{staticClass:"demo-badge",attrs:{href:"#"}})])],1):t._e(),i("div",{staticClass:"picimage"},[i("img",{directives:[{name:"lazy",rawName:"v-lazy",value:e.poster||e.satt_dir,expression:"item.poster || item.satt_dir"}],class:e.isSelect?"on":"",on:{click:function(i){return i.stopPropagation(),t.changImage(e,a,t.pictrueList)}}})]),i("div",{staticClass:"picName"},[e.isEdit?i("Input",{attrs:{size:"small",type:"text"},on:{"on-blur":function(i){return t.bindTxt(e)}},model:{value:e.real_name,callback:function(i){t.$set(e,"real_name",i)},expression:"item.real_name"}}):i("p",{attrs:{title:e.editName}},[t._v("\r\n "+t._s(e.editName)+"\r\n ")]),i("div",{staticClass:"picMenu"},[i("Button",{on:{click:function(t){e.isEdit=!e.isEdit}}},[t._v("\r\n 重命名\r\n ")]),i("Button",{staticClass:"preview",on:{click:function(e){return t.preview(a)}}},[t._v("\r\n 查看\r\n ")]),i("Button",{on:{click:function(i){return t.editPicList(e.att_id)}}},[t._v("\r\n 删除\r\n ")])],1)],1),i("div",{directives:[{name:"show",rawName:"v-show",value:e.realName&&e.real_name,expression:"item.realName && item.real_name"}],staticClass:"nameStyle"},[1==e.file_type?i("img",{attrs:{src:e.satt_dir}}):2==e.file_type?i("div",{attrs:{id:"player"+e.att_id}}):t._e()])])})),0):t._e(),2==t.layout?i("Table",{key:"list",ref:"selection",attrs:{columns:t.columns4,data:t.pictrueList},on:{"on-selection-change":t.selectionChange},scopedSlots:t._u([{key:"poster",fn:function(e){var a=e.row,s=e.index;return[i("img",{directives:[{name:"lazy",rawName:"v-lazy",value:a.satt_dir,expression:"row.satt_dir"},{name:"viewer",rawName:"v-viewer",value:{navbar:!1,toolbar:!1},expression:"{navbar:false,toolbar:false}"}],ref:"sattDir"+s}),i("div",[t._v(t._s(a.editName))])]}},{key:"action",fn:function(e){var a=e.row,s=e.index;return[i("Button",{attrs:{type:"text"},on:{click:function(e){return t.editPicList(a.att_id)}}},[t._v("删除")]),i("Button",{attrs:{type:"text"},on:{click:function(e){return t.rename(s)}}},[t._v("重命名")]),i("Button",{attrs:{type:"text"},on:{click:function(e){return t.preview(s)}}},[t._v("查看")])]}}],null,!1,1106146729)}):t._e()],1)],1),i("div",{staticClass:"footer acea-row row-right"},[i("Page",{attrs:{total:t.total,"show-elevator":"","show-total":"",current:t.fileData.page,"page-size":t.fileData.limit},on:{"on-change":t.pageChange}})],1)])])],1),i("Modal",{attrs:{width:"1024px",scrollable:"","footer-hide":"",closable:"",title:"上传视频","mask-closable":!1,"z-index":9},model:{value:t.modalVideo,callback:function(e){t.modalVideo=e},expression:"modalVideo"}},[i("uploadVideo",{attrs:{pid:t.fileData.pid},on:{getVideo:t.getvideo}})],1),i("uploadImg",{attrs:{categories:t.treeData,"category-id":t.treeId},on:{success:t.uploadSuccess},model:{value:t.uploadVisible,callback:function(e){t.uploadVisible=e},expression:"uploadVisible"}})],1)}),[],!1,null,"0909a912",null);e.default=y.exports}}]);