import{d as $,X as v,Y as G,a0 as q,Z as r,f as a,u as t,E as S,aa as V,e as W,k as O,a6 as z,a9 as N,a7 as H,_ as U,g as X}from"./vue-fae2b924.js";import{at as L,a1 as I,a0 as C,b0 as Y,aC as Z,a$ as J,aa as A,ab as R,G as k,aA as Q,a3 as ee,aK as te,aV as M,M as ae}from"./radical-8b52065e.js";import{a as P,u as ne,C as oe}from"./content-55cf41b5.js";import{_ as se,a as le}from"./operate.vue_vue_type_script_setup_true_lang-79cf25ad.js";import{c as re,e as ie,f as ce,h as de,i as ue}from"./gb28181-293aa46f.js";import{k as pe}from"./index-ee8befd0.js";import{u as me}from"./index-ac72395e.js";import"./play.vue_vue_type_script_setup_true_lang-9e34e6c0.js";import"./jb4-ws-flv-0075830a.js";import"./canvas-220fadcb.js";import"./index-92c1aed7.js";const fe=$({__name:"menu",props:{handleMenuClick:{type:Function},item:{}},setup(p){return(o,e)=>(v(),G(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(I),{key:"add"},{default:r(()=>[a(t(C),{icon:"basil:add-solid",class:"v-text-bottom"}),e[3]||(e[3]=S(" 创建分组 "))]),_: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(I),{key:"add"},{default:r(()=>[a(t(C),{icon:"basil:add-solid",class:"v-text-bottom"}),e[4]||(e[4]=S(" 创建分组 "))]),_:1}),a(t(I),{key:"channel"},{default:r(()=>[a(t(C),{icon:"material-symbols:camera-video-rounded",class:"v-text-bottom"}),e[5]||(e[5]=S(" 通道管理 "))]),_:1}),o.item.channels.length?(v(),G(t(I),{key:"screen"},{default:r(()=>[a(t(C),{icon:"mdi:play-box",class:"v-text-bottom"}),e[6]||(e[6]=S(" 分组上墙 "))]),_:1})):V("",!0),a(t(I),{key:"update"},{default:r(()=>[a(t(C),{icon:"ri:edit-box-fill",class:"v-text-bottom"}),e[7]||(e[7]=S(" 组名编辑 "))]),_:1}),a(t(I),{key:"delete"},{default:r(()=>[a(t(C),{icon:"material-symbols:delete-sharp",class:"v-text-bottom"}),e[8]||(e[8]=S(" 删除分组 "))]),_: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([]),b=O(!0),i=u=>{x("menu",u)},_=u=>{n.value=u,b.value=!1},T=(u,{node:y})=>{const l=n.value.filter(c=>c!==u[0]);l.length(v(),z("div",he,[a(t(J),{showIcon:"","tree-data":s.value,defaultExpandAll:"","expanded-keys":n.value,"auto-expand-parent":b.value,onExpand:_,selectedKeys:m.value,onSelect:T,blockNode:"",fieldNames:{title:"name"}},{title:r(({name:l,isChannel:c,channels:g,id:d,pid:f,channelName:h,channelId:F})=>[N("div",xe,[N("span",null,[c?(v(),G(t(C),{key:0,icon:"mdi:web-camera",class:"v-text-bottom text-primary"})):(v(),G(t(C),{key:1,icon:"uis:layer-group",class:"v-text-bottom"})),N("span",{class:H({"text-primary":c})}," "+U(l||h||F),3)]),c?V("",!0):(v(),G(fe,{key:0,item:{name:l,id:d,pid:f,channels:g},class:"float-right pt-1 pr-2",handleMenuClick:w=>i({name:l,key:w,id:d,pid:f,channels:g})},null,8,["item","handleMenuClick"]))])]),_:1},8,["tree-data","expanded-keys","auto-expand-parent","selectedKeys"])]))}}),D=()=>({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}=A({schema:D()});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}=A({schema:D()});m.setValues({name:e}),R({content:()=>a(x,null,null),modalConfig:{title:`更新「${e}」组名称`,maskClosable:!1,width:700,onOk:async()=>{const{name:b}=await n();await ie({name:b,pid:s,id:o}),k.success("组名更新成功"),p()},onClose:()=>{m.reset()}}})},Ce=$({name:"Channel"}),be=$({...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,_)=>new Promise(async T=>{const{data:u,total:y}=await ce(o.id,{page:i,count:_}),l=u.filter(c=>c.inGroup);e.setSelChannel(l),T({total:y,data:u})}),n=me(),b={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,_)=>(v(),G(t(pe),{uid:t(n).uid,gridOptions:b,onCheckboxAll:x,onCheckboxChange:s},null,8,["uid"]))}}),ve=P(),_e=()=>ve.selectedChannel.filter(o=>o.inGroup).map(o=>({channelId:o.channelId,deviceId:o.deviceId})),we=(p,o,e,s)=>{R({content:a(be,{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"}),ze=$({...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}),b=l=>{ae.confirm({title:"确定删除分组?",cancelText:"取消",okText:"确定",content:"删除后分组及其子分组都将无法使用!",onOk:()=>{ue(l).then(()=>{k.success("分组已删除!"),s()})}})},i=ne(),_=(l,c)=>{if(e.curPlayGroupId===c)return k.warning("当前分组有设备正在播放,无法上墙!");const{streamList:g,resetStreamList:d}=i.multiPlayRef;let f=0;const h=l.map(w=>{const{deviceId:E,channelId:K,deviceName:j,channelName:B}=w;return w.status!=="ON"?(f++,null):{path:`${E}/${K}`,deviceItem:{parentId:E,deviceId:K,parentName:j,name:B}}}).filter(w=>w!==null);f&&(h.length?k.info(`已过滤 ${f} 个不在线的设备!!!`):k.info("所有设备皆不在线!"),f=0);const F=h.length>i.curScreenNum?h.slice(0,i.curScreenNum):h.concat(g.slice(h.length));d(F)},T=l=>{const{deviceId:c,channelId:g,deviceName:d,channelName:f,status:h,groupId:F}=l;if(e.setCurPlayGroupId(F),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":_(h,d),e.setCurPlayGroupId(d);break;case"update":ke(s,d,g,f);break;case"delete":if(d===e.curPlayGroupId)return k.warning("当前分组有设备正在播放,无法删除!");b(d);break}};return(l,c)=>(v(),z("div",Se,[a(t(M),{class:"w-342px m-r-8px flex-shrink-0",bordered:!1,bodyStyle:{height:"100%",padding:0}},{default:r(()=>[N("div",Ie,[c[0]||(c[0]=N("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:T})]),_:1}),a(t(M),{class:"flex-1",bordered:!1,bodyStyle:{height:"100%",padding:"16px"}},{default:r(()=>[a(oe)]),_:1}),N("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{ze as default};