diff --git a/src/views/kc/jiaoshi/index.vue b/src/views/kc/jiaoshi/index.vue index e4ac29a..4a2e812 100644 --- a/src/views/kc/jiaoshi/index.vue +++ b/src/views/kc/jiaoshi/index.vue @@ -70,7 +70,7 @@ - +
{{ (leftList.filter(x => !x?.child['教师近景']?.isOnLine).length || 0) }}
@@ -116,38 +116,38 @@
- + - + - + - + - + - + 请选择 - + - + 请选择 - + - + 请选择 正常 部分正常 @@ -155,18 +155,18 @@ - + - + 请选择 - + - + 请选择 @@ -175,24 +175,39 @@ - - 查询 - 重置 + 查询 + 重置 - - - - + 批量打开直播 + 批量关闭直播 + 批量打开听课 + 批量关闭听课 + + + +
- + + - + @@ -310,6 +325,7 @@ const showAllLiveRef = ref(); const leftList:Ref = ref([]); const cardList:Ref = ref([]); +const selectedRowKeys :Ref = ref([]); const currentItem:Ref = ref({}); const currentCardIndex:Ref = ref(0); const allClassNum:Ref = ref(0); @@ -318,7 +334,7 @@ const allClassNum:Ref = ref(0); const showAllLiveKey:Ref = ref('showAllLiveKey'); const isShowAllLive:Ref = ref(false); const loading:Ref = ref(false); -const { createMessage, createInfoModal } = useMessage(); +const { createMessage, createInfoModal, createErrorModal } = useMessage(); const route = useRouter(); const queryParam:Ref = ref({}); @@ -351,11 +367,11 @@ const shangXianQuartz = ref({}); const labelCol = reactive({ xs: { span: 24 }, - sm: { span: 7 }, + sm: { span: 6 }, }); const wrapperCol = reactive({ xs: { span: 24 }, - sm: { span: 16 }, + sm: { span: 19 }, }); const ipagination = ref( @@ -407,6 +423,7 @@ function loadData(){ let map = {}; let jxlMap = {}; list.forEach(x => { + x.zbgn = 0; let item = map[x.jsmc]; x.isOnLine = false; if(item){ @@ -523,6 +540,109 @@ function ylLive(record){ }) } +function onSelectChange(selectedRowKeyList: string | number[]){ + selectedRowKeys.value = selectedRowKeyList; +} + +function checkSelectValue(){ + return checkIsList(selectedRowKeys.value); +} + +function checkIsList(list){ + let r = !!(list??[]).length; + if(!r){ + createErrorModal({ title: '错误', content: '请选择有效数据!' }); + } + return !r; +} + +function getSelectData(expression){ + //筛选数据 + let keyMaps = {}; + selectedRowKeys.value.forEach(x => keyMaps[x] = true); + let changeList = filterComputedDataSource.value.filter(x => keyMaps[x.jsbh] && expression(x)); + return changeList; +} + +function batchLive(type: boolean){ + if(checkSelectValue()) return; + let changeList = getSelectData((x) => x?.child['教师全景']?.isOnLine == !type); + if(checkIsList(changeList)) return; + loading.value = true; + //调用接口 + let ids:any = []; + let isEnable = type; + changeList.forEach(x => ids.push(x?.child['教师全景']?.id)) + if(!ids) return; + changeAvyLiveApi({ ids:ids.join(','), type: isEnable?1:0 }).then(res => { + let content = ''; + res.forEach(x => { + // content += x.jsmc + "-" + x.xm + content += x.jsmc + let text = ''; + if(x.resText){ + if(x.resText.includes('ok')){ + text = (isEnable?'开启':'关闭')+'直播-操作成功!' + }else{ + text = (isEnable?'开启':'关闭')+'直播-操作失败: 录播主机故障,请联系管理员。' + } + } + content += " " + text + "
" + }); + if(content.includes('直播-操作成功!')){ + //延迟12秒 + setTimeout(() => { + loadData(); + createInfoModal({ width:'50%', title: '结果',content }) + }, 12*1000); + }else{ + loadData(); + createInfoModal({ width:'50%', title: '结果',content }) + } + + }).catch(e => { + console.error(e); + loading.value = false; + createInfoModal({title: '错误结果',content:e}) + }) +} + +function batchTingke(type: boolean){ + if(checkSelectValue()) return; + let changeList = getSelectData((x) => x?.sfyx == type?1:0); + if(checkIsList(changeList)) return; + //调用接口 + let ids:any = []; + changeList.forEach(record => Object.values(record.child).forEach(x => { + let item:any = x; + ids.push(item.id); + })) + + if(!ids) return; + updateAllLive({ ids: ids.join(','), sfyx: type?0:1}).then(res => { + loadData(); + }).catch(e => { + console.error(e); + loading.value = false; + }); +} + +function batchLiveOpen(){ + batchLive(true); +} + +function batchLiveClose(){ + batchLive(false); +} + +function batchTingkeOpen(){ + batchTingke(true); +} + +function batchTingkeClose(){ + batchTingke(false); +} + function ylLiveNew(record) { let routeData = route.resolve({ path:'/site/liveRoom2',query:{ id: record.jsbh } }); window.open(routeData.href, '_blank'); @@ -620,8 +740,8 @@ function filterDataSource() { if(qw.sfyx){ isReturn = x.sfyx == qw.sfyx; } - if(qw.sfyx2){ - isReturn = x.sfyx == qw.sfyx2; + if(qw.zbgn){ + isReturn = x.zbgn == qw.zbgn; } if(qw.onLineClassType){ isReturn = x.onLineClassType == qw.onLineClassType;