index-163e87d4-1714037397871.js 15 KB

1
  1. import{d as K,r as C,b as q,e as O,y as oe,p as W,bB as b,f as e,k as y,L as H,bC as z,C as le,j as w,w as R,Q as J,S as X,N as se,v as Q,aB as ne,g as $,h as ue,G as ie,F as re,l as ce,B as de,bD as pe,P as Y}from"./index-f9fea9d9-1714037397871.js";import{u as fe}from"./catchData-30c07abc-1714037397871.js";import{b as me,d as ge,e as Z,g as ye,h as ve,j as be,k as Ae}from"./api-4e0645e9-1714037397871.js";import{C as Fe,g as P,a as ee,o as he}from"./index-70fd6298-1714037397871.js";import{i as Ce}from"./index-cc23b6a3-1714037397871.js";import{N as Be}from"./Scrollbar-38dc678b-1714037397871.js";const Ie="_uploadModal_eir1m_1",Se="_formModal_eir1m_4",_e="_formSpace_eir1m_8",we="_previewModal_eir1m_11",Ue="_image_eir1m_23",Ee="_titleType_eir1m_32",ke="_iconUploadDelete_eir1m_40",De="_commonType_eir1m_55",Ne="_changeCover_eir1m_74",Ge="_formItem_eir1m_91",Me="_btnGroup_eir1m_116",je="_uploadFile_eir1m_123",Te="_uploadBtn_eir1m_130",xe="_iconUploadAdd_eir1m_147",Oe="_uploadCover_eir1m_152",h={uploadModal:Ie,formModal:Se,formSpace:_e,previewModal:we,image:Ue,titleType:Ee,iconUploadDelete:ke,commonType:De,changeCover:Ne,formItem:Ge,btnGroup:Me,uploadFile:je,uploadBtn:Te,iconUploadAdd:xe,uploadCover:Oe},Re="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAYAAADFeBvrAAAAAXNSR0IArs4c6QAAA3xJREFUaEPdmk1oE1EQgL/8qQVRVATxoCIqRURBBIsHKQZqTqJgIR4EPUgbf+6Fpoq2hd79IUWwggcDFRRPsRApHkRBBEVEVEQ9iCAqilBt/syE3bJds9l922xa38Ke9r2Z+d6bmZ15uyE0u0It4BEdUUNPEagEqbPZQG3AemAtsNy4F9kApoEfxv0J+ABMNQuyGUBLgY3ABmCNT8M+A++Bd8AvnzJq0+YC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headerItem_t4tbc_42",Qe="_uploadContainer_t4tbc_59",$e="_imgCropperSection_t4tbc_85",Ye="_uploadBtnGroup_t4tbc_92",_={uploadFile:Le,uploadBtn:Pe,iconUploadAdd:Ve,uploadHeader:Ke,headerItem:qe,uploadContainer:Qe,imgCropperSection:$e,uploadBtnGroup:Ye},Ze=K({name:"upload-file",props:{img:{type:String,default:""},accept:{type:String,default:".jpg,.png,.jpeg,.gif"},bucketName:{type:String,default:"gyt"},path:{type:String,default:""},fileName:{type:String,default:""},options:{type:Object,default:()=>({viewMode:0,autoCrop:!0,enlarge:1,autoCropWidth:640,autoCropHeight:360,fixedBox:!1,previewsCircle:!0,title:"上传图片"})}},emits:["close","confirm"],setup(a,{emit:A}){const I=C(),U="https://".concat(a.bucketName,".ks3-cn-beijing.ksyuncs.com/"),k=q(),l=C(!1),f=C(!1),G=C(),F=C({img:"",autoCrop:!0,autoCropWidth:180,autoCropHeight:180,fixedBox:!0,full:!1,enlarge:1,previewsCircle:!0,centerBox:!0,outputType:"png",title:"修改头像",name:null}),v=O({myCropper:null,cropperReady:!1}),S=async m=>{const d=m.file;let g=!0;if((d.type.includes("image")?b.IMG:d.type.includes("audio")?b.SONG:b.VIDEO)!==b.IMG)return k.error("上传文件格式错误"),!1;const N=10;return g=d.file.size/1024/1024<N,g?(M(d.file,j=>{p(j,d.file.name)}),!1):(k.error("图片大小不能超过".concat(N,"M")),!1)},M=async(m,d)=>{const g=new FileReader;g.addEventListener("load",()=>d(g.result)),g.readAsDataURL(m)},p=(m,d)=>{const g=Object.assign({},a.options,{img:m,name:d});l.value=!0,F.value=Object.assign({},F.value,g),J(()=>{o()})},o=()=>{try{v.cropperReady=!0,v.myCropper=new Fe(I.value,{viewMode:1,dragMode:"move",aspectRatio:F.value.autoCropWidth/F.value.autoCropHeight,initialAspectRatio:1,autoCropArea:1,cropBoxMovable:!0,cropBoxResizable:!0,background:!0,movable:!1,modal:!0,preview:".before",ready:()=>{v.cropperReady=!1}})}catch(m){}},s=()=>{v.myCropper.getCroppedCanvas({imageSmoothingQuality:"high"}).toBlob(m=>{f.value=!0,c(m)})},c=async m=>{try{const d="".concat(a.path).concat(a.fileName||new Date().getTime()+".png"),g={filename:d,bucketName:a.bucketName,postData:{filename:d,acl:"public-read",key:d}},{data:D}=await P(g),N={policy:D.policy,signature:D.signature,acl:"public-read",key:d,KSSAccessKeyId:D.kssAccessKeyId,name:d,file:m},j=await ee(U,N);A("confirm",j),A("close")}catch(d){}f.value=!1};return oe(()=>a.img,()=>{a.img&&V(a.img)===b.IMG&&p(a.img)}),W(()=>{a.img&&V(a.img)===b.IMG&&p(a.img)}),()=>e("div",{class:_.uploadFile},[e("div",{class:_.uploadHeader},[e("div",{class:_.headerItem},[y("上传封面")])]),l.value?e("div",{class:_.uploadContainer},[e(le,{show:v.cropperReady},{default:()=>{var m,d,g;return[e("div",{class:_.imgCropperSection},[((m=F.value)==null?void 0:m.img)&&e("img",{ref:I,src:(d=F.value)==null?void 0:d.img,style:{opacity:(g=v.myCropper)!=null&&g.ready?"1":"0"},alt:""},null)])]}})]):e("div",{class:_.uploadContainer},[e(H,{ref:G,accept:a.accept,multiple:!1,max:1,showFileList:!1,showPreviewButton:!0,onBeforeUpload:m=>S(m)},{default:()=>[e(z,null,{default:()=>[e("div",{class:_.uploadBtn},[e("img",{src:Ce,class:_.iconUploadAdd},null),e("p",null,[y("点击或将图片拖至此区域")]),e("span",null,[y("(建议比例16:9)")])])]})]})]),e("div",{class:_.uploadBtnGroup},[l.value?e(w,{type:"default",onClick:()=>{F.value.img="",l.value=!1}},{default:()=>[y("重新选择")]}):e("span",null,null),e(R,null,{default:()=>[e(w,{type:"default",onClick:()=>A("close")},{default:()=>[y("取消")]}),e(w,{type:"primary",onClick:()=>s(),disabled:!l.value,loading:f.value},{default:()=>[y("保存封面")]})]})])])}});function We(a){return typeof a=="function"||Object.prototype.toString.call(a)==="[object Object]"&&!de(a)}const V=a=>a?(a==null?void 0:a.indexOf(".mp3"))>-1?b.SONG:(a==null?void 0:a.indexOf(".mp4"))>-1?b.VIDEO:(a==null?void 0:a.indexOf(".ppt"))>-1?b.PPT:b.IMG:"",nt=K({name:"upload-modal",props:{list:{type:Array,default:()=>[]},showDelete:{type:Boolean,default:!1},editStatus:{type:Boolean,default:!0}},emits:["close","confirm","editAll"],setup(a,{emit:A}){const I=fe(),U=C(),k=q(),l=O({list:[],uploading:!1,uploadUrl:"",name:"",subjectIds:[]}),f=O({uploadCoverStatus:!1,uploadType:"",uploadImg:null,uploadIndex:0}),G=p=>{let o=Z;switch(p){case"IMG":o=Z;break;case"VIDEO":o=Ae;break;case"SONG":o=be;break;case"MUSIC":o=ve;break;case"PPT":o=ye;break}return o},F=async()=>{var p;(p=U.value)==null||p.validate(async o=>{if(o){J(pe);return}l.uploading=!0;try{const s=[];if(l.list.forEach(c=>{s.push({subjectIds:c.subjectIds.join(","),openFlag:c.openFlag,coverImg:c.coverImg,name:c.name,type:c.type,enableFlag:1,content:c.content,id:c.id||null})}),S.value){if(a.editStatus)A("editAll",s);else{const{data:c}=await me(s);k.success("保存成功"),l.list=[],A("close",!0),A("confirm",c)}l.list=[]}else await ge(s),k.success("保存成功"),l.list=[],A("close",!0),A("confirm")}catch(s){}l.uploading=!1})},v=p=>{l.list.splice(p,1)},S=X(()=>a.list.length>0);W(async()=>{const p=a.list||[],o=[];p.forEach(s=>{o.push({subjectIds:s.subjectId?s.subjectId.split(",").map(c=>Number(c)):[],openFlag:s.openFlag,coverImg:s.coverImg,name:s.title,type:s.type,sourceFrom:s.sourceFrom,enableFlag:s.enableFlag,content:s.content,id:s.id})}),l.list=o||[],await I.getSubjects()});const M=(p,o)=>{p.subjectIds=o.map(s=>s.id)};return()=>{let p;return e("div",{class:h.uploadModal},[e(Be,{style:{"max-height":"55vh"}},{default:()=>[e(se,{ref:U,labelPlacement:"left",labelWidth:120,model:l,class:h.formModal},{default:()=>[e(R,{class:h.formSpace},We(p=l.list.map((o,s)=>e("div",{class:h.formItem,key:s},[e("div",{class:h.previewModal},[e(Q,{class:[h.titleType],src:G(o.type),previewDisabled:!0,objectFit:"cover"},null),(!S.value||a.showDelete)&&e("img",{class:[h.iconUploadDelete],src:Re,onClick:()=>v(s)},null),e(Q,{class:[h.cover,h.image],lazy:!0,previewDisabled:!0,src:o.coverImg,objectFit:"cover"},null),e("div",{class:h.commonType},[e(w,{class:h.changeCover,type:"default",bordered:!1,onClick:()=>{f.uploadIndex=s,f.uploadImg=o.coverImg,f.uploadType=o.type,f.uploadCoverStatus=!0}},{default:()=>[y("更换封面")]}),e("div",null,[y("是否公开"),e(ne,{size:"small",value:o.openFlag,"onUpdate:value":c=>o.openFlag=c,disabled:o.sourceFrom==="TEACHER"&&o.type==="MUSIC"},null)])])]),e($,{showFeedback:!1,path:"list.".concat(s,".name"),rule:[{required:!0,message:"请输入资源名称",trigger:["input","blur"]}]},{default:()=>[e(ue,{value:o.name,"onUpdate:value":c=>o.name=c,placeholder:"请输入资源名称",maxlength:25,clearable:!0},null)]}),e($,{path:"list[".concat(s,"].subjectIds"),showFeedback:!1,rule:[{required:!0,message:"请选择素材可用声部",trigger:"change",type:"array"}]},{default:()=>[e(ie,{value:o.subjectIds,"onUpdate:value":c=>o.subjectIds=c,placeholder:"请选择素材可用声部(可多选)",options:I.getSubjectList,labelField:"name",valueField:"id",multiple:!0,maxTagCount:2,clearable:!0},{action:()=>e(re,null,[e(w,{text:!0,style:" --n-width: 100% ",onClick:()=>M(o,I.getSubjectList)},{default:()=>[y("全选")]})])})]})])))?p:{default:()=>[p]})]})]}),e(R,{class:h.btnGroup,justify:"center"},{default:()=>[e(w,{round:!0,onClick:()=>A("close")},{default:()=>[a.editStatus?"取消":"上一步"]}),e(w,{round:!0,type:"primary",loading:l.uploading,disabled:l.list.length===0,onClick:F},{default:()=>[y("确定")]})]}),e(ce,{show:f.uploadCoverStatus,"onUpdate:show":o=>f.uploadCoverStatus=o,preset:"card",showIcon:!1,class:["modalTitle ",h.uploadCover],blockScroll:!1},{default:()=>[e(Ze,{img:f.uploadImg,onClose:()=>f.uploadCoverStatus=!1,onConfirm:o=>{f.uploadType==="IMG"&&(l.list[f.uploadIndex].content=o),l.list[f.uploadIndex].coverImg=o}},null)]})])}}}),He="_saveModal_ulplg_1",ze="_uploadBtn_ulplg_25",Je="_iconUploadAdd_ulplg_47",Xe="_btnGroup_ulplg_57",x={saveModal:He,uploadBtn:ze,iconUploadAdd:Je,btnGroup:Xe},ut=K({name:"save-modal",props:{fileList:{type:String,default:""},imageList:{type:Array,default:()=>[]},accept:{type:String,default:".jpg,.png,.jpeg,.gif"},showType:{type:String,default:"default"},showFileList:{type:Boolean,default:!0},max:{type:Number,default:1},multiple:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},bucketName:{type:String,default:"gyt"},directoryDnd:{type:Boolean,default:!1},path:{type:String,default:""},fileName:{type:String,default:""}},emits:["close","confrim"],setup(a,{emit:A}){const I="https://".concat(a.bucketName,".ks3-cn-beijing.ksyuncs.com/"),U=q(),k=C(!1),l=C(!1),f=C(),G=C(),F=O([]),v=C([]),S=C([]);function M(t){return t.slice((t.lastIndexOf(".")-1>>>0)+2)}function p(t,n){const i=M(t).toLowerCase();return n.includes(i)}const o=async t=>{const n=t.file;let i=!0;const u=["jpg","jpeg","png","mp4","ppt","pptx"];if(!p(n.file.name,u))return U.error("文件格式不支持"),!1;const r=n.type.includes("image")?b.IMG:n.type.includes("audio")?b.SONG:n.type.includes("video")?b.VIDEO:n.type.includes("vnd.openxmlformats-officedocument.presentationml.presentation")||n.type.includes("vnd.ms-powerpoint")?b.PPT:"other";if(r==="other")return U.error("文件格式不支持"),!1;const B=r==="IMG"?2:r==="SONG"?20:500;if(B&&(i=n.file.size/1024/1024<B,!i)){const E=r==="IMG"?"图片":r==="SONG"?"音频":"视频";return U.error("".concat(E,"大小不能超过").concat(B,"M")),!1}if(!i)return i;try{l.value=!0;const E=n.file.name,te=E.slice(E.lastIndexOf(".")),T="".concat(a.path).concat(Date.now()+n.id+te),ae={filename:T,bucketName:a.bucketName,postData:{filename:T,acl:"public-read",key:T,unknowValueField:[]}},{data:L}=await P(ae);F.push({id:n.id,tempFiileBuffer:n.file,policy:L.policy,signature:L.signature,acl:"public-read",key:T,KSSAccessKeyId:L.kssAccessKeyId,name:T})}catch(E){return l.value=!1,!1}return!0},s=t=>{c(t)},c=async t=>{console.log(t,"onFinishAfter");const n=F.find(r=>r.id==t.file.id),i=V(t.file.url);let u="";i==="IMG"?u=t.file.url:i==="SONG"?u=Y.SONG_DEFAULT_COVER:i==="PPT"?u=Y.PPT_DEFAULT_COVER:i==="VIDEO"&&(u=await d(n.tempFiileBuffer)),S.value.push({coverImg:u,content:t.file.url,id:t.file.id,name:t.file.name?t.file.name.slice(0,t.file.name.lastIndexOf(".")):""}),k.value=!1,l.value=!1},m=t=>new Promise((n,i)=>{const u=document.createElement("video");u.setAttribute("crossOrigin","Anonymous"),u.setAttribute("preload","auto"),u.muted=!0,u.autoplay=!0,u.src=URL.createObjectURL(t),u.addEventListener("loadedmetadata",()=>{u.play(),setTimeout(()=>{u.currentTime=0,u.pause();const r=document.createElement("canvas");r.width=u.videoWidth,r.height=u.videoHeight,r.getContext("2d").drawImage(u,0,0,r.width,r.height),r.toBlob(B=>{n(B)})},500)}),u.addEventListener("error",r=>{i(r)})}),d=async t=>{try{l.value=!0;const n=await m(t||f.value),i="".concat(a.path).concat(Date.now()+".png"),u={filename:i,bucketName:a.bucketName,postData:{filename:i,acl:"public-read",key:i,unknowValueField:[]}},{data:r}=await P(u),B={policy:r.policy,signature:r.signature,key:i,acl:"public-read",KSSAccessKeyId:r.kssAccessKeyId,name:i,file:n};return await ee(I,B)}finally{l.value=!1}},g=async t=>{const n=S.value.findIndex(i=>i.id===t.file.id);return S.value.splice(n,1),l.value=!1,!0},D=X(()=>{let t=!1;return v.value.forEach(n=>{n.status!=="finished"&&(t=!0)}),t||v.value.length<=0||l.value}),N=({file:t,action:n,onFinish:i,onError:u,onProgress:r})=>{const B=F.find(E=>E.id==t.id);B.file=t,he({file:t,action:n,data:B,onProgress:r,onFinish:i,onError:u})},j=async()=>{const t=[];v.value.forEach(n=>{const i=S.value.find(u=>u.id===n.id);i&&t.push(i)}),A("confrim",t)};return()=>e("div",{class:x.saveModal},[e(H,{ref:G,action:I,customRequest:N,fileList:v.value,"onUpdate:fileList":t=>v.value=t,accept:".jpg,jpeg,.png,audio/mp3,video/mp4,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation",multiple:!0,max:10,showFileList:!0,showPreviewButton:!0,onBeforeUpload:t=>o(t),onFinish:t=>{s(t)},onRemove:t=>g(t)},{default:()=>[e(z,null,{default:()=>[e("div",{class:x.uploadBtn},[e("div",{class:x.iconUploadAdd},null),e("h3",null,[y("点击或者拖动文件到该区域来上传")]),e("p",null,[y("仅支持JPG、PNG、MP3、MP4、PPT格式文件,单次最多支持"),e("br",null,null),y("上传10个文件")])])]})]}),e(R,{class:x.btnGroup,justify:"center"},{default:()=>[e(w,{round:!0,onClick:()=>A("close")},{default:()=>[y("取消")]}),e(w,{round:!0,type:"primary",disabled:D.value||l.value,onClick:j},{default:()=>[y("确定")]})]})])}});export{ut as S,nt as U,V as f};