import{d as y,ah as S,ag as w,r as b,$ as N,c as a,aj as k,q as n,ak as C,P,B as u,o as T,m as i,b9 as I}from"./index.d1dca38b.js";import{s as o}from"./photo.module.55d59b7f.js";import{O as A}from"./index.3aa1e6eb.js";import{L}from"./index.876ff047.js";import{F as q}from"./index.a5f38096.js";import{A as x}from"./index.8d8e6351.js";import"./use-tab-status.03ea8dd0.js";import"./index.2f930c00.js";var $=y({name:"phone",props:{height:{type:[String,Number],default:"auto"}},setup(d){const c=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:c.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:c.query.id,name:e.name,parentId:e.id}})},f=async()=>{t.photoName=t.selectItem.name,t.status=!0},g=async()=>{I({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 N(async()=>{await r()}),()=>a("div",{class:[o.phone,!t.listState.dataShow&&"emptyRootContainer"],style:{minHeight:`calc(100vh - ${d.height}px)`}},[a(A,{position:"top"},{default:()=>[a(k,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(L,{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(C,{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(q,{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(u,{onClick:()=>t.status=!1,class:["van-button van-button--default van-button--large van-dialog__cancel"]},{default:()=>[n("\u53D6\u6D88")]}),a(u,{onClick:h,class:["van-button van-button--default van-button--large van-dialog__confirm van-hairline--left"]},{default:()=>[n("\u786E\u8BA4")]})])])]}),a(x,{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{$ as default};
