photo-create.16578666.js 6.5 KB

1
  1. import{d as _,ah as R,ag as E,r as B,$ as O,c as e,aj as V,B as i,q as n,ak as x,P as w,o as g,m as r,bd as j,bj as S,bv as M,bD as K,bE as k}from"./index.5f7ffb46.js";import{s}from"./photo.module.55d59b7f.js";import{O as $}from"./index.7790de2a.js";import{L as z}from"./index.9ef28852.js";import{F as G}from"./index.6438a25f.js";import{A as H}from"./index.78e196a2.js";import{U as J}from"./index.36e5ddaf.js";import"./use-tab-status.69b57a37.js";import"./index.abd668f7.js";import"./index.4f3f29e9.js";import"./ImagePreview.289405c5.js";import"./index.99e0cf1f.js";import"./index.276a5d68.js";import"./function-call.aca3a7bc.js";var ct=_({name:"phone",props:{height:{type:[String,Number],default:"auto"}},setup(Q){const l=R(),I=E(),t=B({oPopover:!1,showPhoto:!1,status:!1,isLoading:!1,photoName:null,list:[],listState:{dataShow:!0,loading:!1,finished:!1},params:{page:1,rows:20},selectItem:{},selectType:"add",fileList:[],bucket:"gyt"}),P=async()=>{try{if(!t.photoName){g("\u8BF7\u8F93\u5165\u76F8\u518C\u540D\u79F0"),t.status=!0;return}t.selectType==="add"?(await r.post("/api-school/orchestraPhotoAlbum/save",{data:{orchestraId:l.query.orchestraId,name:t.photoName,parentId:l.query.parentId}}),t.status=!1,t.photoName=null,p()):(await r.post("/api-school/orchestraPhotoAlbum/update",{data:{id:t.selectItem.id,orchestraId:l.query.orchestraId,parentId:l.query.parentId,name:t.photoName}}),t.status=!1,t.photoName=null,p())}catch{}},p=()=>{t.params.page=1,t.list=[],t.listState.dataShow=!0,t.listState.loading=!1,t.listState.finished=!1,c()},c=async()=>{try{if(t.isLoading)return;t.isLoading=!0;const a=await r.post("/api-school/orchestraPhotoAlbum/page",{data:{...t.params,orchestraId:l.query.orchestraId,parentId:l.query.parentId}});t.listState.loading=!1;const o=a.data||{};if(t.list.length>0&&o.current===1)return;const d=o.rows||[];t.list=t.list.concat(d),t.listState.finished=o.current>=o.pages,t.params.page=o.current+1,t.listState.dataShow=t.list.length>0,t.isLoading=!1}catch{t.listState.dataShow=!1,t.listState.finished=!0,t.isLoading=!1}},C=a=>{sessionStorage.setItem("orchestra-detail-tab","photo"),I.push({path:"/photo-detail",query:{photoId:a.id,name:a.name}})},L=async()=>{t.photoName=t.selectItem.name,t.status=!0},F=async()=>{j({message:"\u60A8\u786E\u8BA4\u5220\u9664\u8BE5\u76F8\u518C\u5417\uFF1F"}).then(async()=>{try{await r.post("/api-school/orchestraPhotoAlbum/remove",{requestType:"form",data:{id:t.selectItem.id}}),p()}catch{}})};O(()=>{c()});const N=a=>a.size/1024/1024<5?!0:(g("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 5MB"),!1),T=(a,o)=>!0,A=async(a,o)=>{try{a.status="uploading",a.message="\u4E0A\u4F20\u4E2D...",await D(a)}catch{S()}},D=async a=>{try{console.log(a,"files");const o=a.file,d="/api-school/open/getUploadSign",v=o.name||"",u="/orchestra/"+(v&&v.replace(/ /gi,"_")),h=new Date().getTime()+u,m=await r.post(d,{data:{filename:u,bucketName:t.bucket,postData:{filename:u,acl:"public-read",key:h,unknowValueField:[]}}});M({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0});const b={policy:m.data.policy,signature:m.data.signature,key:h,KSSAccessKeyId:m.data.kssAccessKeyId,acl:"public-read",name:u},f=new FormData;for(const y in b)f.append(y,b[y]);f.append("file",o,u),await K(k(t.bucket),{method:"POST",data:f});const q=k(t.bucket)+h;S(),a.src=q,a.status="done"}catch(o){a.status="failed",console.log(o,"uploadFile")}},U=async()=>{try{if(t.fileList.length<=0){g("\u8BF7\u4E0A\u4F20\u7167\u7247");return}const a=t.fileList.map(o=>o.src);console.log(a,"onSubmitPhoto"),await r.post("/api-school/orchestraPhoto/save",{data:{orchestraId:l.query.orchestraId,orchestraPhotoAlbumId:l.query.parentId,fileUrl:a.join(",")}}),t.showPhoto=!1,t.fileList=[],t.params.page=1,t.list=[],t.listState.dataShow=!0,t.listState.loading=!1,t.listState.finished=!1,c()}catch{}};return()=>e("div",{class:!t.listState.dataShow&&"emptyRootContainer"},[e($,{position:"top"},{default:()=>[e(V,{title:"\u521B\u5EFA\u76F8\u518C"},null),e("div",{class:s.btnGroup},[e(i,{icon:"plus",block:!0,class:s.addPhone,onClick:()=>{t.photoName="",t.status=!0,t.selectType="add"}},{default:()=>[n("\u65B0\u5EFA\u76F8\u518C")]}),e(i,{icon:"plus",block:!0,class:s.addPhone,onClick:()=>t.showPhoto=!0},{default:()=>[n("\u4E0A\u4F20\u7167\u7247")]})])]}),e("div",{class:s.phone},[t.listState.dataShow?e(z,{finished:t.listState.finished,finishedText:" ",onLoad:c,immediateCheck:!1,class:s.informationGroup},{default:()=>[e("div",{class:s.phoneContainer},[t.list.map(a=>e("div",{class:s.item,onClick:()=>C(a)},[e("i",{class:s.more,onClick:o=>{o.stopPropagation(),t.oPopover=!0,t.selectItem=a,t.selectType="update"}},null),e("div",{class:s.img,style:a.coverUrl?{backgroundImage:`url(${a.coverUrl})`,backgroundSize:"cover"}:""},null),e("p",{class:[s.name,"van-ellipsis"]},[a.name]),e("p",{class:s.num},[a.photoCount,n("\u5F20")])]))])]}):e(x,{btnStatus:!1,tips:"\u6682\u65E0\u76F8\u518C"},null),e(w,{show:t.status,"onUpdate:show":a=>t.status=a,round:!0,style:{width:"80%"}},{default:()=>[e("div",{class:s.container},[e("div",{class:s.dialogTitle},[e("i",null,null),t.selectType==="add"?"\u65B0\u5EFA\u76F8\u518C":"\u91CD\u547D\u540D\u76F8\u518C"]),e(G,{class:s.phoneName,modelValue:t.photoName,"onUpdate:modelValue":a=>t.photoName=a,placeholder:"\u8BF7\u8F93\u5165\u76F8\u518C\u540D\u79F0",maxlength:15},null),e("div",{class:["van-hairline--top van-dialog__footer"]},[e(i,{onClick:()=>t.status=!1,class:["van-button van-button--default van-button--large van-dialog__cancel"]},{default:()=>[n("\u53D6\u6D88")]}),e(i,{onClick:P,class:["van-button van-button--default van-button--large van-dialog__confirm van-hairline--left"]},{default:()=>[n("\u786E\u8BA4")]})])])]}),e(H,{cancelText:"\u53D6\u6D88",show:t.oPopover,"onUpdate:show":a=>t.oPopover=a,closeOnClickAction:!0,actions:[{name:"\u91CD\u547D\u540D",callback:()=>L()},{name:"\u5220\u9664",color:"#F44541",callback:()=>F()}]},null)]),e(w,{show:t.showPhoto,"onUpdate:show":a=>t.showPhoto=a,round:!0,style:{width:"92%"}},{default:()=>[e("div",{class:s.container},[e("div",{class:s.dialogTitle},[e("i",null,null),n("\u4E0A\u4F20\u7167\u7247")]),e("div",{class:s.photos},[e(J,{modelValue:t.fileList,"onUpdate:modelValue":a=>t.fileList=a,afterRead:A,beforeRead:N,beforeDelete:T,accept:"image/*",maxCount:9},null)]),e("div",{class:["van-hairline--top van-dialog__footer"]},[e(i,{onClick:()=>{t.showPhoto=!1,t.fileList=[]},class:["van-button van-button--default van-button--large van-dialog__cancel"]},{default:()=>[n("\u53D6\u6D88")]}),e(i,{onClick:U,class:["van-button van-button--default van-button--large van-dialog__confirm van-hairline--left"]},{default:()=>[n("\u786E\u8BA4")]})])])]})])}});export{ct as default};