Merge pull request 'zouyf_dev' (#361) from zouyf_dev into main

Reviewed-on: #361
This commit is contained in:
zouyf 2024-10-24 14:49:33 +08:00
commit 812e799e2a
2 changed files with 70 additions and 33 deletions

View File

@ -18,13 +18,13 @@ export class Chat {
}
return Chat.instance;
}
/**
* 初始化 获取IM签名
* @param {*} isInit : 是否初始化IM
* @param {*} isLogin : 是否登录IM
* @param {*} callback: 监听消息回调函数
* @returns Promise<ImChat>
*/
/**
* 初始化 获取IM签名
* @param {*} isInit : 是否初始化IM
* @param {*} isLogin : 是否登录IM
* @param {*} callback: 监听消息回调函数
* @returns Promise<ImChat>
*/
async init(isInit = true, isLogin = true, callback) {
// 特殊处理只传1个参数且为函数则默认为callbackisInit和isLogin默认为true
if (typeof isInit == 'function'){

View File

@ -157,6 +157,7 @@ import ItemDialogScore from '@/views/classTask/container/classTask/item-dialog-s
import quizStats from '@/views/classTask/container/quizStats.vue'
import ClassOverview from '@/views/classTask/container/classOverview.vue'
import {sessionStore} from '@/utils/store'
import Chat from '@/utils/chat' // im
const { proxy } = getCurrentInstance()
@ -204,35 +205,38 @@ const classWorkAnalysisScore = reactive({
// form.name = newValue.label
// }
// )
const openDialog = (data) => {
const openDialog = (data, isInit=true) => {
console.log(data, '点击的item完成情况')
if (isInit) {
classWorkAnalysis.title = data.uniquekey ? data.uniquekey + '--' : ''
classWorkAnalysis.worktype = data.worktype
classWorkAnalysis.workclass = data.workclass
//
tableRadio.list = []
tableRadio.value = '1'
tableRadio.num0 = 0
tableRadio.num1 = 0
classWorkAnalysis.title = data.uniquekey ? data.uniquekey + '--' : ''
classWorkAnalysis.worktype = data.worktype
classWorkAnalysis.workclass = data.workclass
//
tableRadio.list = []
tableRadio.value = '1'
tableRadio.num0 = 0
tableRadio.num1 = 0
classWorkAnalysis.open = true
//
classWorkAnalysis.view = 'studentview'
// ID
classWorkAnalysis.entpcourseworklistarray = data.entpcourseworklistarray
//
classWorkAnalysis.activeStudentQuizlist = []
//
classWorkAnalysis.activeQuizAnalysisData = []
classWorkAnalysis.open = true
//
classWorkAnalysis.view = 'studentview'
// ID
classWorkAnalysis.entpcourseworklistarray = data.entpcourseworklistarray
//
classWorkAnalysis.activeStudentQuizlist = []
//
classWorkAnalysis.activeQuizAnalysisData = []
classWorkAnalysis.row = data
window.test = this
// zdg:
const studentArr = data.classworkdatastudentids
? JSON.parse(`[${data.classworkdatastudentids}]`)
: []
classWorkActiveData.studentList = studentArr
classWorkAnalysis.row = data
window.test = this
// zdg:
const studentArr = data.classworkdatastudentids
? JSON.parse(`[${data.classworkdatastudentids}]`)
: []
classWorkActiveData.studentList = studentArr
}
/** 学生完成情况分析--获取作业学生list数据 */
getClassWorkStudentList(data.id)
@ -638,6 +642,32 @@ const closeDialog = () => {
emit('cle-click')
}
// im
const msgHandle = (msg) => {
const { type, data } = msg
switch(type) {
case 'TIMAddRecvNewMsgCallback': // data=[]
{
(data||[]).forEach(o => {
const msgArr = o?.message_elem_array||[]
msgArr.forEach(info => {
const msgType = info?.elem_type // TIMElemType
const msgData = !!info.text_elem_content ? JSON.parse(info.text_elem_content)||'' : ''
//
//console.log('msgData->', msgData);
if (msgData.msgKey == "finishHomework"){
//
const data = JSON.parse(localStorage.getItem('teachClassWorkItem'));
//console.log('data->', data);
openDialog(data, false);
}
})
})
}
break
}
}
const reloadTimer = ref(0); // id
const cutid = ref(0); // id
onMounted(() => {
@ -649,6 +679,13 @@ onMounted(() => {
//
cutid.value = data.id;
isReloadTimer();
// im
if (!Chat.imChat) {
Chat.init(true, true, msgHandle);
} else {
Chat.listenMsg(msgHandle);
}
})
const isReloadTimer = () =>{
clearInterval(reloadTimer.value) //