import{d as y,ah as S,ag as w,r as b,$ as C,c as a,aj as N,q as n,ak as k,P,B as c,o as T,m as i,bd as F}from"./index.5f7ffb46.js";import{s as o}from"./photo.module.55d59b7f.js";import{O as I}from"./index.7790de2a.js";import{L as A}from"./index.9ef28852.js";import{F as L}from"./index.6438a25f.js";import{A as D}from"./index.78e196a2.js";import"./use-tab-status.69b57a37.js";import"./index.abd668f7.js";var E=y({name:"phone",props:{height:{type:[String,Number],default:"auto"}},setup(d){const u=S(),p=w(),t=b({oPopover:!1,status:!1,isLoading:!1,photoName:null,list:[],listState:{dataShow:!0,loading:!1,finished:!1},params:{page:1,rows:20},selectItem:{},selectType:"add",schoolStatus:!1,schoolList:[],school:{}}),h=async()=>{try{if(!t.photoName){T("\u8BF7\u8F93\u5165\u76F8\u518C\u540D\u79F0"),t.status=!0;return}t.selectType==="add"?(await i.post("/api-school/orchestraPhotoAlbum/save",{data:{name:t.photoName}}),t.status=!1,t.photoName=null,l()):(await i.post("/api-school/orchestraPhotoAlbum/update",{data:{id:t.selectItem.id,orchestraId:u.query.id,name:t.photoName}}),t.status=!1,t.photoName=null,l()),t.status=!1,t.photoName=null,l()}catch{}},l=()=>{t.params.page=1,t.list=[],t.listState.dataShow=!0,t.listState.loading=!1,t.listState.finished=!1,r()},r=async()=>{try{if(t.isLoading)return;t.isLoading=!0;const e=await i.post("/api-school/orchestraPhotoAlbum/page",{data:{...t.params,schoolId:t.school.id}});t.listState.loading=!1;const s=e.data||{};if(t.list.length>0&&s.current===1)return;const v=s.rows||[];t.list=t.list.concat(v),t.listState.finished=s.current>=s.pages,t.params.page=s.current+1,t.listState.dataShow=t.list.length>0,t.isLoading=!1}catch{t.listState.dataShow=!1,t.listState.finished=!0,t.isLoading=!1}},m=e=>{sessionStorage.setItem("orchestra-detail-tab","photo"),p.push({path:"/orchestra-photo-create",query:{orchestraId:u.query.id,name:e.name,parentId:e.id}})},f=async()=>{t.photoName=t.selectItem.name,t.status=!0},g=async()=>{F({message:"\u60A8\u786E\u8BA4\u5220\u9664\u8BE5\u76F8\u518C\u5417\uFF1F"}).then(async()=>{try{await i.post("/api-school/orchestraPhotoAlbum/remove",{requestType:"form",data:{id:t.selectItem.id}}),l()}catch{}})};return C(async()=>{await r()}),()=>a("div",{class:[o.phone,!t.listState.dataShow&&"emptyRootContainer"],style:{minHeight:`calc(100vh - ${d.height}px)`}},[a(I,{position:"top"},{default:()=>[a(N,null,{right:()=>a("span",{class:o.addPhotoTop,onClick:()=>{t.photoName="",t.status=!0,t.selectType="add"}},[n("\u6DFB\u52A0\u76F8\u518C")])})]}),t.listState.dataShow?a(A,{finished:t.listState.finished,finishedText:" ",onLoad:r,immediateCheck:!1,class:o.informationGroup},{default:()=>[a("div",{class:o.phoneContainer},[t.list.map(e=>a("div",{class:o.item,onClick:()=>m(e)},[a("i",{class:o.more,onClick:s=>{s.stopPropagation(),t.oPopover=!0,t.selectItem=e,t.selectType="update"}},null),a("div",{class:o.img,style:e.coverUrl?{backgroundImage:`url(${e.coverUrl})`,backgroundSize:"cover"}:""},null),a("p",{class:[o.name,"van-ellipsis"]},[e.name]),a("p",{class:o.num},[e.photoCount,n("\u5F20")])]))])]}):a(k,{btnStatus:!1,tips:"\u6682\u65E0\u76F8\u518C"},null),a(P,{show:t.status,"onUpdate:show":e=>t.status=e,round:!0,style:{width:"80%"}},{default:()=>[a("div",{class:o.container},[a("div",{class:o.dialogTitle},[a("i",null,null),t.selectType==="add"?"\u65B0\u5EFA\u76F8\u518C":"\u91CD\u547D\u540D\u76F8\u518C"]),a(L,{class:o.phoneName,modelValue:t.photoName,"onUpdate:modelValue":e=>t.photoName=e,placeholder:"\u8BF7\u8F93\u5165\u76F8\u518C\u540D\u79F0",maxlength:15},null),a("div",{class:["van-hairline--top van-dialog__footer"]},[a(c,{onClick:()=>t.status=!1,class:["van-button van-button--default van-button--large van-dialog__cancel"]},{default:()=>[n("\u53D6\u6D88")]}),a(c,{onClick:h,class:["van-button van-button--default van-button--large van-dialog__confirm van-hairline--left"]},{default:()=>[n("\u786E\u8BA4")]})])])]}),a(D,{cancelText:"\u53D6\u6D88",show:t.oPopover,"onUpdate:show":e=>t.oPopover=e,closeOnClickAction:!0,actions:[{name:"\u91CD\u547D\u540D",callback:()=>f()},{name:"\u5220\u9664",color:"#F44541",callback:()=>g()}]},null)])}});export{E as default};