import{z as c,B as l}from"./index.f5168bf8.js";import{d as u}from"./data-report.0c7c73f2.js";import{n as m}from"./vueComponentNormalizer.9ef17bb1.js";function d(e){return e("div",{class:"r_t_image"},[e("img",{attrs:{src:this.src,draggable:"false"},style:`transform:translate(${this.image.x}px, ${this.image.y}px) scale(${this.image.s}) rotate(${this.image.r}deg)`,on:{mousedown:this.onMove}}),e("div",{class:"actions"},[e("i",{class:"el-icon-zoom-in",on:{click:()=>this.imageScale(1)}}),e("i",{class:"el-icon-refresh-right",on:{click:()=>this.imageRotate(1)}}),e("i",{class:"el-icon-full-screen",on:{click:()=>this.onFullScreen()}}),e("i",{class:"el-icon-refresh-left",on:{click:()=>this.imageRotate(-1)}}),e("i",{class:"el-icon-zoom-out",on:{click:()=>this.imageScale(-1)}})])])}function p(e){return e("div",{class:"r_t_mp4"},[e("video",{attrs:{src:this.src,controls:!0,disablePictureInPicture:!0,controlsList:"nodownload noremoteplayback noplaybackrate"},class:{r_t_mp4:1,timeline:this.timeline}})])}function f(e){return e("div",{class:"r_t_mp3"},[e("div",{class:"left"},[e("i",{on:{click:this.playAudio},class:"icon i-"+["bofang","zanting"][this.mp3.state]})]),e("div",{class:"right"},[e("p",{attrs:{"data-label":"\u6587\u4EF6\u540D\u79F0"}},[this.resource.name]),e("p",{attrs:{"data-label":"\u6587\u4EF6\u5927\u5C0F"}},[this.resource.size.formatFileSize()]),e("p",{attrs:{"data-label":"\u4E0A\u4F20\u65F6\u95F4"}},[new Date(this.resource.createTime).format("yyyy-MM-dd")]),e("div",{class:"progress",on:{click:this.onClickProgress},style:{"--progress":this.mp3.current_time/this.mp3.duration}}),e("div",{class:"times",attrs:{"data-current-time":this.formatAudioTime(this.mp3.current_time),"data-duration-time":this.formatAudioTime(this.mp3.duration)}}),e("audio",{ref:"audioRef",attrs:{src:this.src},on:{canplay:this.onAudioCanplay,ended:()=>this.mp3.state=0}})])])}function h(e){return e("div",{class:"r_t_pdf"},[e("iframe",{attrs:{src:this.src}}),e("div",{class:"actions"},[e("i",{class:"el-icon-full-screen",on:{click:()=>this.onFullScreen()}})])])}const r={image:d,audio:f,video:p,pdf:h},g={props:{timeline:{type:Boolean},resource:{type:Object}},data:()=>({src:null,isFullScreen:!1,mp3:{state:0,current_time:0,duration:0},image:{x:0,y:0,s:1,r:0},errorMsg:null}),created(){var t;const e=c(this.resource.mimetype);!e||(this.viewType=r[e]?e:"pdf",this.src=(t=this.resource.preview)==null?void 0:t.fileLinkTransfer(),this.src||this.toConver(this.resource),window.addEventListener("resize",()=>{this.isFullScreen=!!document.fullscreenElement}))},methods:{async toConver(e){try{const{data:t}=await l(e.id);e.preview=t,this.resource===e&&(this.src=t.fileLinkTransfer())}catch{this.errorMsg="\u6587\u4EF6\u8F6C\u6362\u5931\u8D25"}},imageScale(e){const t=this.image.s+e*.2;t>=.6&&t<=2&&(this.image.s=t)},imageRotate(e){this.image.r=this.image.r+e*90},onFullScreen(){this.isFullScreen?document.exitFullscreen():this.$el.requestFullscreen()},onMove(e){const t=this.image.x,i=this.image.y,o=e.pageX,n=e.pageY;document.body.onmouseup=()=>{e.target.onmouseup=null,e.target.onmousemove=null},e.target.onmousemove=s=>{this.image.x=t+s.pageX-o,this.image.y=i+s.pageY-n}},onClickProgress(e){this.$refs.audioRef.currentTime=this.mp3.duration*e.offsetX/300},formatAudioTime(e){return`${Math.floor(e/60).toString().padStart(2,0)}:${Math.ceil(e%60).toString().padStart(2,0)}`},onAudioCanplay(e){const t=({target:i})=>{this.mp3.current_time=i.currentTime,this.mp3.duration=i.duration};e.target.addEventListener("timeupdate",t),t(e)},playAudio(){this.$refs.audioRef.paused?(this.$refs.audioRef.play(),this.mp3.state=1):(this.$refs.audioRef.pause(),this.mp3.state=0)}},render(e){var t;return this.viewType?this.errorMsg?e("div",{class:"load_file_error"},[this.errorMsg]):this.src?e("div",{class:{resource_layout:1,"is-full":this.isFullScreen}},[(t=r[this.viewType])==null?void 0:t.call(this,e)]):e("div",{class:"load_file"},["\u6587\u4EF6\u52A0\u8F7D\u4E2D\uFF0C\u8BF7\u7A0D\u540E..."]):e("div",{class:"no_resource_preview"},["\u8BE5\u6587\u4EF6\u6682\u4E0D\u652F\u6301\u9884\u89C8"])},mixins:[u("RESOURCE_VIEW",{isCancelReport(){return!this.viewType},handleReportData(){return{field01:this.resource.id}}})]};let _,v;const a={};var y=m(g,_,v,!1,F,null,null,null);function F(e){for(let t in a)this[t]=a[t]}const k=function(){return y.exports}();export{k as P};
