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