1 |
- import{d as F,aV as R,ag as O,r as V,$ as x,c as e,B as i,q as n,ai as B,P as w,o as g,m as r,b6 as E,be as S,bl as M,bv as K,bw as k}from"./index.ffe80dbe.js";import{s}from"./photo.module.55d59b7f.js";import{O as $}from"./index.a0ef77e4.js";import{O as j}from"./index.4ddd16f0.js";import{L as z}from"./index.cafcb8b5.js";import{F as G}from"./index.92ec0bf4.js";import{A as H}from"./index.84851ef1.js";import{U as J}from"./index.329d98a9.js";import"./index.1d5c6f70.js";import"./use-tab-status.5a3cd090.js";import"./index.ea031708.js";import"./index.9bed9ddc.js";import"./ImagePreview.fb0145e9.js";import"./index.b4b77b5a.js";import"./index.7e972106.js";import"./function-call.4b573eb9.js";var pt=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},N=async()=>{E({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 T=a=>a.size/1024/1024<5?!0:(g("\u4E0A\u4F20\u6587\u4EF6\u5927\u5C0F\u4E0D\u80FD\u8D85\u8FC7 5MB"),!1),A=(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 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(j,{position:"top"},{default:()=>[e($,{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(B,{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:()=>N()}]},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:T,beforeDelete:A,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{pt as default};
|