import{d as $,X as _,Y as N,a0 as q,Z as r,f as a,u as t,E as I,aa as A,e as W,k as O,a6 as V,a9 as T,a7 as H,_ as U,g as X}from"./vue-fae2b924.js";import{at as L,a1 as G,a0 as C,b2 as Y,aC as Z,b1 as J,aa as j,ab as R,G as k,aA as Q,a3 as ee,aK as te,aV as M,M as ae}from"./radical-e583b742.js";import{a as P,u as ne,C as oe}from"./content-0a943ef8.js";import{_ as se,a as le}from"./operate.vue_vue_type_script_setup_true_lang-67a45f97.js";import{e as re,f as ie,h as ce,i as de,j as ue}from"./gb28181-c1c04a54.js";import{k as pe}from"./index-7a259168.js";import{u as me}from"./index-ac72395e.js";import"./canvas-14fb4930.js";import"./index-3ee11f11.js";const fe=$({__name:"menu",props:{handleMenuClick:{type:Function},item:{}},setup(p){return(o,e)=>(_(),N(t(Z),{trigger:"click",placement:"bottomRight",onClick:e[2]||(e[2]=s=>s.stopPropagation())},q({default:r(()=>[a(t(Y))]),_:2},[o.item.pid===0?{name:"overlay",fn:r(()=>[a(t(L),{onClick:e[0]||(e[0]=s=>o.handleMenuClick(s.key))},{default:r(()=>[a(t(G),{key:"add"},{default:r(()=>[a(t(C),{icon:"basil:add-solid",class:"v-text-bottom"}),e[3]||(e[3]=I(" 创建分组 "))]),_:1})]),_:1})]),key:"0"}:{name:"overlay",fn:r(()=>[a(t(L),{onClick:e[1]||(e[1]=s=>o.handleMenuClick(s.key))},{default:r(()=>[a(t(G),{key:"add"},{default:r(()=>[a(t(C),{icon:"basil:add-solid",class:"v-text-bottom"}),e[4]||(e[4]=I(" 创建分组 "))]),_:1}),a(t(G),{key:"channel"},{default:r(()=>[a(t(C),{icon:"material-symbols:camera-video-rounded",class:"v-text-bottom"}),e[5]||(e[5]=I(" 通道管理 "))]),_:1}),o.item.channels.length?(_(),N(t(G),{key:"screen"},{default:r(()=>[a(t(C),{icon:"mdi:play-box",class:"v-text-bottom"}),e[6]||(e[6]=I(" 分组上墙 "))]),_:1})):A("",!0),a(t(G),{key:"update"},{default:r(()=>[a(t(C),{icon:"ri:edit-box-fill",class:"v-text-bottom"}),e[7]||(e[7]=I(" 组名编辑 "))]),_:1}),a(t(G),{key:"delete"},{default:r(()=>[a(t(C),{icon:"material-symbols:delete-sharp",class:"v-text-bottom"}),e[8]||(e[8]=I(" 删除分组 "))]),_:1})]),_:1})]),key:"1"}]),1024))}}),he={class:"m-16px overscroll-contain overflow-y-auto overflow-x-hidden",style:{height:"100%"}},xe={class:"flex justify-between"},ye=$({__name:"index",emits:["menu","select"],setup(p,{emit:o}){const e=P();e.fetchGroupTree();const s=W(()=>e.groupTree),x=o,m=O([]),n=O([]),v=O(!0),i=u=>{x("menu",u)},S=u=>{n.value=u,v.value=!1},F=(u,{node:y})=>{const l=n.value.filter(c=>c!==u[0]);l.length(_(),V("div",he,[a(t(J),{showIcon:"","tree-data":s.value,defaultExpandAll:"","expanded-keys":n.value,"auto-expand-parent":v.value,onExpand:S,selectedKeys:m.value,onSelect:F,blockNode:"",fieldNames:{title:"name"}},{title:r(({name:l,isChannel:c,channels:g,id:d,pid:f,channelName:h,channelId:w})=>[T("div",xe,[T("span",null,[c?(_(),N(t(C),{key:0,icon:"mdi:web-camera",class:"v-text-bottom text-primary"})):(_(),N(t(C),{key:1,icon:"uis:layer-group",class:"v-text-bottom"})),T("span",{class:H({"text-primary":c})}," "+U(l||h||w),3)]),c?A("",!0):(_(),N(fe,{key:0,item:{name:l,id:d,pid:f,channels:g},class:"float-right pt-1 pr-2",handleMenuClick:b=>i({name:l,key:b,id:d,pid:f,channels:g})},null,8,["item","handleMenuClick"]))])]),_:1},8,["tree-data","expanded-keys","auto-expand-parent","selectedKeys"])]))}}),z=()=>({type:"object",properties:{layout:{type:"void","x-component":"FormLayout","x-component-props":{layout:"horizontal",labelCol:6,wrapperCol:14},properties:{name:{type:"string",title:"设备名称","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"请输入组名称",allowClear:!0},required:!0}}}}}),ge=(p,o,e)=>{const{FormilyForm:s,form:x,submit:m}=j({schema:z()});R({content:()=>a(s,null,null),modalConfig:{title:`在「${e}」下添加组`,maskClosable:!1,width:700,onOk:async()=>{const{name:n}=await m();await re({name:n,pid:o}),k.success("分组添加成功"),p()},onClose:()=>{x.reset()}}})},ke=(p,o,e,s)=>{const{FormilyForm:x,form:m,submit:n}=j({schema:z()});m.setValues({name:e}),R({content:()=>a(x,null,null),modalConfig:{title:`更新「${e}」组名称`,maskClosable:!1,width:700,onOk:async()=>{const{name:v}=await n();await ie({name:v,pid:s,id:o}),k.success("组名更新成功"),p()},onClose:()=>{m.reset()}}})},Ce=$({name:"Channel"}),ve=$({...Ce,props:{id:{}},setup(p){const o=p,e=P(),s=()=>{if(n!=null&&n.tableRef){const i=n.tableRef.getCheckboxRecords();e.setSelChannel(i)}},x=()=>{if(n!=null&&n.tableRef){const i=n.tableRef.getCheckboxRecords();e.setSelChannel(i)}},m=(i,S)=>new Promise(async F=>{const{data:u,total:y}=await ce(o.id,{page:i,count:S}),l=u.list.filter(c=>c.inGroup);e.setSelChannel(l),F({total:y,data:u.list})}),n=me(),v={maxHeight:"530px",rowConfig:{keyField:"channelId",useKey:!0},columnConfig:{useKey:!0},pagerConfig:{pageSize:10},proxyConfig:{seq:!0,props:{result:"data",total:"total"},ajax:{query:({page:i})=>m(i.currentPage,i.pageSize)}},checkboxConfig:{checkField:"inGroup"},columns:[{type:"checkbox",width:50,fixed:"left"},{field:"channelId",title:"通道编号",showOverflow:"tooltip",width:"200px",fixed:"left"},{field:"channelName",title:"通道名称",showOverflow:"tooltip",width:"120px",fixed:"left"},{field:"deviceId",title:"设备编号",showOverflow:"tooltip",width:"200px",fixed:"left"},{field:"deviceName",title:"设备名称",showOverflow:"tooltip",minWidth:"120px",fixed:"left"},{field:"streamMode",title:"流传输模式",minWidth:"100px"},{field:"status",title:"状态",minWidth:"80px"}]};return(i,S)=>(_(),N(t(pe),{uid:t(n).uid,gridOptions:v,onCheckboxAll:x,onCheckboxChange:s},null,8,["uid"]))}}),be=P(),_e=()=>be.selectedChannel.filter(o=>o.inGroup).map(o=>({channelId:o.channelId,deviceId:o.deviceId})),we=(p,o,e,s)=>{R({content:a(ve,{id:s},null),modalConfig:{appContext:p,width:"78%",title:`${e} 通道管理`,okText:"更新",cancelText:"关闭",maskClosable:!1,onOk:async()=>{await de({groupId:s,channelIds:_e()}),k.success("分组通道已更新"),o()}}})},Se={class:"flex",style:{height:"calc(100% - 8px)"}},Ie={class:"flex items-center justify-between p-8px"},Ge={class:"w-300px m-l-8px h-full flex-shrink-0"},Ne=$({name:"Screen"}),Le=$({...Ne,setup(p){var y;const o=(y=X())==null?void 0:y.appContext,e=P(),s=()=>{e.fetchGroupTree()};function x(){return new Promise(async l=>{await e.fetchGroupTree(),setTimeout(()=>{l({})},1200)})}const{loading:m,handleFn:n}=Q(x,{immediate:!1}),v=l=>{ae.confirm({title:"确定删除分组?",cancelText:"取消",okText:"确定",content:"删除后分组及其子分组都将无法使用!",onOk:()=>{ue(l).then(()=>{k.success("分组已删除!"),s()})}})},i=ne(),S=(l,c)=>{if(e.curPlayGroupId===c)return k.warning("当前分组有设备正在播放,无法上墙!");const{streamList:g,resetStreamList:d}=i.multiPlayRef;let f=0;const h=l.map(b=>{const{deviceId:E,channelId:K,deviceName:D,channelName:B}=b;return b.status!=="ON"?(f++,null):{path:`${E}/${K}`,deviceItem:{parentId:E,deviceId:K,parentName:D,name:B}}}).filter(b=>b!==null);f&&(h.length?k.info(`已过滤 ${f} 个不在线的设备!!!`):k.info("所有设备皆不在线!"),f=0);let w;if(h.length>i.curScreenNum)w=h.slice(0,i.curScreenNum);else{const b=new Array(g.length).fill({}).map(()=>({path:"",deviceItem:{},stream:void 0}));w=h.concat(b.slice(h.length))}d(w)},F=l=>{const{deviceId:c,channelId:g,deviceName:d,channelName:f,status:h,groupId:w}=l;if(e.setCurPlayGroupId(w),h!=="ON")return k.error("设备不在线");i.setActiveInfo({parentId:c,deviceId:g,parentName:d,name:f})},u=l=>{const{key:c,name:g,id:d,pid:f,channels:h}=l;switch(c){case"add":ge(s,d,g);break;case"channel":if(d===e.curPlayGroupId)return k.warning("当前分组有设备正在播放,无法管理通道!");we(o,s,g,d);break;case"screen":S(h,d),e.setCurPlayGroupId(d);break;case"update":ke(s,d,g,f);break;case"delete":if(d===e.curPlayGroupId)return k.warning("当前分组有设备正在播放,无法删除!");v(d);break}};return(l,c)=>(_(),V("div",Se,[a(t(M),{class:"w-342px m-r-8px flex-shrink-0",bordered:!1,bodyStyle:{height:"100%",padding:0}},{default:r(()=>[T("div",Ie,[c[0]||(c[0]=T("span",{class:"text-14px"},"设备分组",-1)),a(t(ee),{placement:"left",title:"更新设备分组"},{default:r(()=>[a(t(C),{icon:"ant-design:redo-outlined",class:"v-text-bottom cursor-pointer",size:"18",infinite:t(m),onClick:t(n)},null,8,["infinite","onClick"])]),_:1})]),a(t(te),{class:"m-0"}),a(ye,{onMenu:u,onSelect:F})]),_:1}),a(t(M),{class:"flex-1",bordered:!1,bodyStyle:{height:"100%",padding:"16px"}},{default:r(()=>[a(oe)]),_:1}),T("div",Ge,[a(t(M),{class:"m-b-8px",bordered:!1,bodyStyle:{height:"230px",padding:0}},{default:r(()=>[a(se)]),_:1}),a(t(M),{style:{height:"calc(100% - 238px)"},bordered:!1,bodyStyle:{height:"100%",padding:0}},{default:r(()=>[a(le)]),_:1})])]))}});export{Le as default};