import{b0 as v,bp as F,n as s,bc as I,d as D,Z as k,a1 as q,a0 as u,T as p,a2 as $,b4 as w,b9 as O,bn as S,a5 as b,a6 as R,aG as B,aQ as N,ba as L}from"./index-1f7267da.js";import{u as M}from"./index-4ed641ec.js";import{x as W,y as j,z,A as T}from"./gb28181-59fe2452.js";import"./dayjs-919e6097.js";const E=({handleSubmit:t,handleReset:r,handleAdd:d})=>({type:"object",properties:{layout:{type:"void","x-component":"FormLayout","x-component-props":{layout:"inline",style:"marginTop: 22px",labelCol:8,wrapperCol:16},properties:{query:{type:"string",title:"通道检索","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"通道编号,自定义通道编号,通道名称,自定义通道名称",allowClear:!0,style:{width:"300px",marginRight:"16px",boxSizing:"border-box"},"@pressEnter":()=>t()}},type:{type:"number",title:"通道类型",enum:[{label:"全部",value:-1},{label:"设备通道",value:0},{label:"自定义通道",value:1}],"x-decorator":"FormItem","x-component":"Select","x-component-props":{style:{width:"160px",marginRight:"8px"},"@inputKeyDown":i=>i.key==="Enter"&&t()},default:-1},btns:{type:"void","x-component":"FormButtonGroup","x-component-props":{style:"marginLeft: 8px"},properties:{submit:{type:"void","x-component":"Button","x-component-props":{type:"primary","@click":()=>t(),style:"width: 70px;"},"x-content":"查询"},reset:{type:"void","x-component":"Button","x-component-props":{"@click":()=>r(),style:"width: 70px"},"x-content":"重置"},add:{type:"void","x-component":"Button","x-component-props":{type:"primary","@click":()=>d(),style:"width: 120px"},"x-content":"添加自定义通道"}}}}}}}),A=()=>({type:"object",properties:{layout:{type:"void","x-component":"FormLayout","x-component-props":{labelCol:8,wrapperCol:16},properties:{deviceId:{type:"string",title:"设备ID","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"不填则与通道ID一致",allowClear:!0},"x-validator":[{pattern:/^\d{20}$/,message:"设备ID必须为20位数字"}]},channelId:{type:"string",title:"通道ID","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"请输入通道ID",allowClear:!0},required:!0,"x-validator":[{required:!0,pattern:/^\d{20}$/,message:"通道ID必须为20位数字"}]},customChannelId:{type:"string",title:"自定义通道ID","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"不填则与通道ID一致",allowClear:!0},"x-validator":[{pattern:/^\d{20}$/,message:"自定义通道ID必须为20位数字"}]},channelName:{type:"string",title:"通道名称","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"请输入通道名称",allowClear:!0},required:!0},customChannelName:{type:"string",title:"自定义通道名称","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"不填则与通道名称一致",allowClear:!0}},streamPath:{type:"string",title:"流路径","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"请输入流路径",allowClear:!0},required:!0}}}}}),K=(t,r=!1)=>({type:"object",properties:{layout:{type:"void","x-component":"FormLayout","x-component-props":{labelCol:8,wrapperCol:16},properties:{deviceId:{type:"string",title:"设备ID","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"不填则与通道ID一致",allowClear:!0,disabled:!r},"x-validator":[{pattern:/^\d{20}$/,message:"设备ID必须为20位数字"}]},channelId:{type:"string",title:"通道ID","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"请输入通道ID",allowClear:!0,disabled:!r},required:!0,"x-validator":[{required:!0,pattern:/^\d{20}$/,message:"通道ID必须为20位数字"}]},customChannelId:{type:"string",title:"自定义通道ID","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"不填则与通道ID一致",allowClear:!0},"x-reactions":[{dependencies:[".channelId"],when:"{{$deps[0] !== undefined}}",fulfill:{state:{value:"{{$deps[0]}}"}}}],"x-validator":[{pattern:/^\d{20}$/,message:"自定义通道ID必须为20位数字"}]},channelName:{type:"string",title:"通道名称","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"请输入通道名称",allowClear:!0,disabled:!r},required:!0},customChannelName:{type:"string",title:"自定义通道名称","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:"不填则与通道名称一致",allowClear:!0}},streamPath:{type:"string",title:"流路径","x-decorator":"FormItem","x-component":"Input","x-component-props":{placeholder:t?"有值时不允许删除":"无值时不允许填写",allowClear:!1,disabled:!t},required:!!t}}}}}),V=t=>{const{FormilyForm:r,form:d,submit:i}=v({schema:A()});F({content:()=>s(r,null,null),modalConfig:{title:"新增通道",maskClosable:!1,width:"600px",onOk:async()=>{const a=await i();if(a){const x=a.deviceId||a.channelId,h=a.channelId,n={id:`${x}_${h}`,deviceId:x,channelId:h,customChannelId:a.customChannelId||h,channelName:a.channelName,customChannelName:a.customChannelName||a.channelName,streamPath:a.streamPath};return await W(n),I.success("新增成功"),t(),Promise.resolve(!0)}return Promise.reject(!1)},onClose:()=>{d.reset()}}})},G=(t,r)=>{const d=!!t.streamPath,i=d,{FormilyForm:a,form:x,submit:h}=v({schema:K(i,d),formProps:{initialValues:{deviceId:t.deviceId,channelId:t.channelId,customChannelId:t.customChannelId,channelName:t.channelName,customChannelName:t.customChannelName,streamPath:t.streamPath}}});F({content:()=>s(a,null,null),modalConfig:{title:"编辑通道",maskClosable:!1,width:"600px",onOk:async()=>{const n=await h();if(n){const y=n.deviceId||n.channelId,l=n.channelId,C={id:`${y}_${l}`,deviceId:y,channelId:l,customChannelId:n.customChannelId||l,channelName:n.channelName,customChannelName:n.customChannelName||n.channelName,streamPath:i?n.streamPath:void 0};return await j(C),I.success("编辑成功"),r(),Promise.resolve(!0)}return Promise.reject(!1)},onClose:()=>{x.reset()}}})},Q=D({name:"ChannelManage"}),Y=D({...Q,setup(t){const r=async()=>{n.submit(),!(n.errors.length>0)&&l.tableRef.commitProxy("query")},d=()=>{n.reset(),l.tableRef.commitProxy("query")},i=()=>{V(()=>{l.tableRef.commitProxy("query")})},a=o=>{if(!o.streamPath){I.warning("设备通道无法修改");return}G(o,()=>{l.tableRef.commitProxy("query")})},x=o=>{if(!o.streamPath){I.warning("设备通道无法删除");return}L.confirm({title:"确认删除",content:`确定要删除通道"${o.channelName||o.channelId}"吗?`,okText:"确认",cancelText:"取消",onOk:async()=>{try{await z(o.id),I.success("删除成功"),l.tableRef.commitProxy("query")}catch(m){console.error("删除失败:",m)}}})},{FormilyForm:h,form:n}=v({schema:E({handleSubmit:r,handleReset:()=>d(),handleAdd:()=>i()})}),y=(o,m)=>new Promise(async c=>{const{query:f,type:P}=n.values,g=await T({query:f,type:P,page:o,count:m}),_=(g.list||g.data||[]).map(e=>({id:e.id||e.ID||e.Id,channelId:e.channelId||e.channelID||e.ChannelId||e.ChannelID||e.ChannelId,customChannelId:e.customChannelId||e.customChannelID||e.CustomChannelId||e.CustomChannelID||e.customChannelId,channelName:e.channelName||e.name||e.Name,customChannelName:e.customChannelName||e.customName||e.CustomName,deviceId:e.deviceId||e.deviceID||e.DeviceId,deviceName:e.deviceName||e.DeviceName,streamPath:e.streamPath||e.StreamPath,status:e.status||e.Status,type:e.streamPath?"自定义通道":"设备通道"}));c({total:g.total||0,data:_})}),l=M(),C={height:"auto",rowConfig:{keyField:"id",useKey:!0},columnConfig:{useKey:!0},pagerConfig:{pageSize:10},proxyConfig:{autoLoad:!0,seq:!0,props:{result:"data",total:"total"},ajax:{query:({page:o})=>y(o.currentPage,o.pageSize)}},columns:[{field:"id",title:"ID",visible:!1},{field:"channelId",title:"通道编号",minWidth:"140px",showOverflow:"tooltip"},{field:"customChannelId",title:"自定义通道编号",minWidth:"160px",showOverflow:"tooltip"},{field:"channelName",title:"通道名称",minWidth:"160px",showOverflow:"tooltip"},{field:"customChannelName",title:"自定义通道名称",minWidth:"160px",showOverflow:"tooltip"},{field:"streamPath",title:"流标识",minWidth:"180px",showOverflow:"tooltip"},{field:"type",title:"通道类型",minWidth:"120px"},{field:"status",title:"在线状态",minWidth:"100px",align:"center",slots:{default:"status"}},{field:"operate",title:"操作",width:"180px",fixed:"right",align:"center",slots:{default:"operate"}}]};return(o,m)=>(k(),q($,null,[s(p(w),{bordered:!1,bodyStyle:{padding:"10px",marginBottom:"8px"}},{default:u(()=>[s(p(h))]),_:1}),s(p(w),{bordered:!1,bodyStyle:{padding:"10px",height:"100%"},style:{height:"calc(100% - 100px)"}},{default:u(()=>[s(p(O),{uid:p(l).uid,gridOptions:C},{status:u(({row:c})=>[s(p(S),{color:c.status==="ON"?"green":"red"},{default:u(()=>[b(R(c.status==="ON"?"在线":"离线"),1)]),_:2},1032,["color"])]),operate:u(({row:c})=>[s(p(B),null,{default:u(()=>[s(p(N),{size:"small",type:"link",disabled:!c.streamPath,onClick:f=>a(c)},{default:u(()=>m[0]||(m[0]=[b(" 修改 ")])),_:2},1032,["disabled","onClick"]),s(p(N),{size:"small",type:"link",danger:"",disabled:!c.streamPath,onClick:f=>x(c)},{default:u(()=>m[1]||(m[1]=[b(" 删除 ")])),_:2},1032,["disabled","onClick"])]),_:2},1024)]),_:1},8,["uid"])]),_:1})],64))}});export{Y as default}; //# sourceMappingURL=index-2a9d4138.js.map