photo-create.35567587.js 6.5 KB

1
  1. import{d as F,ah as R,ag as B,r as O,$ as V,c as e,aj as x,B as i,q as n,ak as E,P as w,o as g,m as r,b9 as M,bf as S,bq as j,bA as K,bB as k}from"./index.3b0304e1.js";import{s}from"./photo.module.55d59b7f.js";import{O as $}from"./index.454c666f.js";import{L as z}from"./index.179b8d2a.js";import{F as G}from"./index.f8e9940f.js";import{A as H}from"./index.5fdd5242.js";import{U as J}from"./index.275ac951.js";import"./use-tab-status.e36e4d74.js";import"./index.ff3f298b.js";import"./index.6a4babff.js";import"./ImagePreview.a30a5f94.js";import"./index.ce8d626c.js";import"./index.710cd200.js";import"./function-call.461228ec.js";var ut=F({name:"phone",props:{height:{type:[String,Number],default:"auto"}},setup(Q){const l=R(),I=B(),t=O({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,u()},u=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},A=async()=>{M({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{}})};V(()=>{u()});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,U=async(a,o)=>{try{a.status="uploading",a.message="\u4E0A\u4F20\u4E2D...",await q(a)}catch{S()}},q=async a=>{try{console.log(a,"files");const o=a.file,d="/api-school/open/getUploadSign",v=o.name||"",c="/orchestra/"+(v&&v.replace(/ /gi,"_")),h=new Date().getTime()+c,m=await r.post(d,{data:{filename:c,bucketName:t.bucket,postData:{filename:c,acl:"public-read",key:h,unknowValueField:[]}}});j({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:c},f=new FormData;for(const y in b)f.append(y,b[y]);f.append("file",o,c),await K(k(t.bucket),{method:"POST",data:f});const D=k(t.bucket)+h;S(),a.src=D,a.status="done"}catch(o){a.status="failed",console.log(o,"uploadFile")}},_=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,u()}catch{}};return()=>e("div",{class:!t.listState.dataShow&&"emptyRootContainer"},[e($,{position:"top"},{default:()=>[e(x,{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:u,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(E,{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:()=>A()}]},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:U,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:_,class:["van-button van-button--default van-button--large van-dialog__confirm van-hairline--left"]},{default:()=>[n("\u786E\u8BA4")]})])])]})])}});export{ut as default};