import{d as F,ah as R,ag as O,r as V,$ as x,c as e,aj as B,B as i,q as n,ak as E,P as w,o as g,m as r,b9 as j,bj as S,bp as M,bz as z,bA as k}from"./index.1c621181.js";import{s}from"./photo.module.55d59b7f.js";import{O as K}from"./index.b491c24a.js";import{L as $}from"./index.d5ee0b18.js";import{F as G}from"./index.c7a20c76.js";import{A as H}from"./index.7c36c16c.js";import{U as J}from"./index.6999cc47.js";import"./use-tab-status.40058c51.js";import"./index.fd5ae97b.js";import"./index.de594f37.js";import"./ImagePreview.410fc85b.js";import"./index.78a302c3.js";import"./index.4c221cbe.js";import"./function-call.db8bb852.js";var ut=F({name:"phone",props:{height:{type:[String,Number],default:"auto"}},setup(Q){const l=R(),I=O(),t=V({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()=>{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{}})};x(()=>{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:[]}}});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:c},f=new FormData;for(const y in b)f.append(y,b[y]);f.append("file",o,c),await z(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(K,{position:"top"},{default:()=>[e(B,{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($,{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};