import{d as S,ah as y,ag as b,r as w,$ as N,c as a,aj as k,B as c,q as n,ak as C,P,o as I,m as i,be as T}from"./index.8f93de0e.js";import{s}from"./photo.module.4e04cf55.js";import{O as A}from"./index.a9a604b9.js";import{L}from"./index.1e20fccc.js";import{F as q}from"./index.9b99667f.js";import{A as x}from"./index.038430de.js";import"./use-tab-status.69e46758.js";import"./index.f729b332.js";var E=S({name:"phone",props:{height:{type:[String,Number],default:"auto"}},setup(d){const u=y(),p=b(),t=w({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){I("\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 o=e.data||{};if(t.list.length>0&&o.current===1)return;const v=o.rows||[];t.list=t.list.concat(v),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}},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()=>{T({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:[s.phone,!t.listState.dataShow&&"emptyRootContainer"],style:{minHeight:`calc(100vh - ${d.height}px)`}},[a(A,{position:"top"},{default:()=>[a(k,{border:!1},null),a("div",{class:s.btnGroup},[a(c,{icon:"plus",block:!0,class:s.addPhone,onClick:()=>{t.photoName="",t.status=!0,t.selectType="add"}},{default:()=>[n("\u65B0\u5EFA\u76F8\u518C")]})])]}),t.listState.dataShow?a(L,{finished:t.listState.finished,finishedText:" ",onLoad:r,immediateCheck:!1,class:s.informationGroup},{default:()=>[a("div",{class:s.phoneContainer},[t.list.map(e=>a("div",{class:s.itemWrap},[a("div",{class:s.item,onClick:()=>m(e)},[a("i",{class:s.more,onClick:o=>{o.stopPropagation(),t.oPopover=!0,t.selectItem=e,t.selectType="update"}},null),a("div",{class:s.imgSection},[a("div",{class:s.img,style:e.coverUrl?{backgroundImage:`url(${e.coverUrl})`,backgroundSize:"cover"}:""},null)]),a("p",{class:[s.name,"van-ellipsis"]},[e.name]),a("p",{class:s.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:s.container},[a("div",{class:s.dialogTitle},[a("i",null,null),t.selectType==="add"?"\u65B0\u5EFA\u76F8\u518C":"\u91CD\u547D\u540D\u76F8\u518C"]),a(q,{class:s.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(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{E as default};
