photo-create.6f1390f8.js 6.4 KB

1
  1. import{d as U,ah as q,ag as _,r as F,$ as D,c as e,aj as R,B as i,q as n,ak as O,P as f,o as m,m as u,b9 as V,bf as g,bq as x,bA as B}from"./index.332c7f08.js";import{s}from"./photo.module.55d59b7f.js";import{O as E}from"./index.d7c1b6ac.js";import{U as M,g as j,o as K}from"./oss-file-upload.e630303f.js";import{L as z}from"./index.b186dfda.js";import{F as G}from"./index.1ed6273e.js";import{A as $}from"./index.1fff19a4.js";import"./index.ee7951f5.js";import"./ImagePreview.e5b44a77.js";import"./index.1e2dfe6e.js";import"./index.96a8db5e.js";import"./function-call.3db51140.js";import"./use-tab-status.9d769af8.js";import"./index.91135ff9.js";var rt=U({name:"phone",props:{height:{type:[String,Number],default:"auto"}},setup(H){const l=q(),v=_(),t=F({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"}),y=async()=>{try{if(!t.photoName){m("\u8BF7\u8F93\u5165\u76F8\u518C\u540D\u79F0"),t.status=!0;return}t.selectType==="add"?(await u.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 u.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,d()},d=async()=>{try{if(t.isLoading)return;t.isLoading=!0;const a=await u.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 r=o.rows||[];t.list=t.list.concat(r),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}},b=a=>{sessionStorage.setItem("orchestra-detail-tab","photo"),v.push({path:"/photo-detail",query:{photoId:a.id,name:a.name}})},w=async()=>{t.photoName=t.selectItem.name,t.status=!0},S=async()=>{V({message:"\u60A8\u786E\u8BA4\u5220\u9664\u8BE5\u76F8\u518C\u5417\uFF1F"}).then(async()=>{try{await u.post("/api-school/orchestraPhotoAlbum/remove",{requestType:"form",data:{id:t.selectItem.id}}),p()}catch{}})};D(()=>{d()});const k=a=>a.size/1024/1024<5?!0:(m("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 5MB"),!1),I=(a,o)=>!0,P=async(a,o)=>{try{a.status="uploading",a.message="\u4E0A\u4F20\u4E2D...",await C(a)}catch{g()}},C=async a=>{try{console.log(a,"files");const o=a.file,r=o.name||"",A="/orchestra/"+(r&&r.replace(/ /gi,"_")),c=new Date().getTime()+A,{data:h}=await j({filename:c,bucketName:t.bucket,postData:{filename:c,acl:"public-read",key:c,unknowValueField:[]}});x({message:"\u52A0\u8F7D\u4E2D...",forbidClick:!0,loadingType:"spinner",duration:0});const N={policy:h.policy,signature:h.signature,key:c,KSSAccessKeyId:h.kssAccessKeyId,acl:"public-read",name:c,file:o},T=await K(B(t.bucket),N);g(),a.src=T,a.status="done"}catch(o){a.status="failed",console.log(o,"uploadFile")}},L=async()=>{try{if(t.fileList.length<=0){m("\u8BF7\u4E0A\u4F20\u7167\u7247");return}const a=t.fileList.map(o=>o.src);console.log(a,"onSubmitPhoto"),await u.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,d()}catch{}};return()=>e("div",{class:!t.listState.dataShow&&"emptyRootContainer"},[e(E,{position:"top"},{default:()=>[e(R,{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:d,immediateCheck:!1,class:s.informationGroup},{default:()=>[e("div",{class:s.phoneContainer},[t.list.map(a=>e("div",{class:s.item,onClick:()=>b(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(O,{btnStatus:!1,tips:"\u6682\u65E0\u76F8\u518C"},null),e(f,{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:y,class:["van-button van-button--default van-button--large van-dialog__confirm van-hairline--left"]},{default:()=>[n("\u786E\u8BA4")]})])])]}),e($,{cancelText:"\u53D6\u6D88",show:t.oPopover,"onUpdate:show":a=>t.oPopover=a,closeOnClickAction:!0,actions:[{name:"\u91CD\u547D\u540D",callback:()=>w()},{name:"\u5220\u9664",color:"#F44541",callback:()=>S()}]},null)]),e(f,{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(M,{modelValue:t.fileList,"onUpdate:modelValue":a=>t.fileList=a,afterRead:P,beforeRead:k,beforeDelete:I,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:L,class:["van-button van-button--default van-button--large van-dialog__confirm van-hairline--left"]},{default:()=>[n("\u786E\u8BA4")]})])])]})])}});export{rt as default};