|
|
|
@ -12,7 +12,7 @@ import {
|
|
|
|
import { SessionState } from 'src/shared/types/session'
|
|
|
|
import { SessionState } from 'src/shared/types/session'
|
|
|
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
|
import { computed, onMounted, onUnmounted, ref, watch } from 'vue'
|
|
|
|
import { api } from '../api'
|
|
|
|
import { api } from '../api'
|
|
|
|
import type { ActionButton } from '../types/action'
|
|
|
|
import type { ActionButton, CallStatus } from '../types/action'
|
|
|
|
|
|
|
|
|
|
|
|
const logErr = async (ctx: string, error: unknown): Promise<void> => {
|
|
|
|
const logErr = async (ctx: string, error: unknown): Promise<void> => {
|
|
|
|
const msg = error instanceof Error ? error.message : String(error)
|
|
|
|
const msg = error instanceof Error ? error.message : String(error)
|
|
|
|
@ -42,7 +42,10 @@ const isActionSuccess = (res: unknown): boolean => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getActionMessage = (res: unknown): string => {
|
|
|
|
const getActionMessage = (res: unknown): string => {
|
|
|
|
return String(getActionData(res).message ?? '')
|
|
|
|
const data = getActionData(res) as { message?: unknown; msg?: unknown }
|
|
|
|
|
|
|
|
if (typeof data.message === 'string') return data.message
|
|
|
|
|
|
|
|
if (typeof data.msg === 'string') return data.msg
|
|
|
|
|
|
|
|
return ''
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const getActionTicketNo = (res: unknown): string => {
|
|
|
|
const getActionTicketNo = (res: unknown): string => {
|
|
|
|
@ -64,7 +67,7 @@ const textColor = ref('#99ccff')
|
|
|
|
const iconColor = ref('#dcdfe6')
|
|
|
|
const iconColor = ref('#dcdfe6')
|
|
|
|
const message = ref('欢迎使用紫云呼叫终端')
|
|
|
|
const message = ref('欢迎使用紫云呼叫终端')
|
|
|
|
// 待机:idle | 呼叫中:calling | 暂停中:paused | 办理中:working | 评价中:evaluating | 呼叫转移中:transferring
|
|
|
|
// 待机:idle | 呼叫中:calling | 暂停中:paused | 办理中:working | 评价中:evaluating | 呼叫转移中:transferring
|
|
|
|
const callStatus = ref('idle')
|
|
|
|
const callStatus = ref<CallStatus>('idle')
|
|
|
|
const callBtnText = ref('呼叫')
|
|
|
|
const callBtnText = ref('呼叫')
|
|
|
|
const pauseBtnText = ref('暂停')
|
|
|
|
const pauseBtnText = ref('暂停')
|
|
|
|
const callingTkt = ref(-1)
|
|
|
|
const callingTkt = ref(-1)
|
|
|
|
@ -198,6 +201,8 @@ function startQueueCountPolling(): void {
|
|
|
|
watch(
|
|
|
|
watch(
|
|
|
|
callStatus,
|
|
|
|
callStatus,
|
|
|
|
status => {
|
|
|
|
status => {
|
|
|
|
|
|
|
|
void window.mainCallStatus.set(status)
|
|
|
|
|
|
|
|
|
|
|
|
if (status === 'evaluating') {
|
|
|
|
if (status === 'evaluating') {
|
|
|
|
startIsRankPolling()
|
|
|
|
startIsRankPolling()
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
@ -333,11 +338,31 @@ const callAction = async (): Promise<void> => {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 刷新日志
|
|
|
|
// 刷新日志
|
|
|
|
const m = getActionMessage(res)
|
|
|
|
const m = getActionMessage(res)
|
|
|
|
updateLog(m)
|
|
|
|
updateLog(m || '呼叫未成功')
|
|
|
|
await window.appLogger.log('warn', `呼叫未成功: ${m}`)
|
|
|
|
await window.appLogger.log(
|
|
|
|
|
|
|
|
'warn',
|
|
|
|
|
|
|
|
`呼叫未成功: windowUid=${w}, empUid=${e}, ticketUid=${t}, response=${JSON.stringify(res)}`,
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (error) {
|
|
|
|
} catch (error) {
|
|
|
|
console.log('error', error)
|
|
|
|
console.log('error', error)
|
|
|
|
|
|
|
|
const w = sessionState.value.winUid || -1
|
|
|
|
|
|
|
|
const e = sessionState.value.empUid || -1
|
|
|
|
|
|
|
|
const t = callingTkt.value > 0 ? callingTkt.value : null
|
|
|
|
|
|
|
|
const detail =
|
|
|
|
|
|
|
|
error instanceof Error
|
|
|
|
|
|
|
|
? error.message
|
|
|
|
|
|
|
|
: (() => {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return JSON.stringify(error)
|
|
|
|
|
|
|
|
} catch {
|
|
|
|
|
|
|
|
return String(error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})()
|
|
|
|
|
|
|
|
await window.appLogger.log(
|
|
|
|
|
|
|
|
'error',
|
|
|
|
|
|
|
|
`呼叫失败: windowUid=${w}, empUid=${e}, ticketUid=${t}, detail=${detail}`,
|
|
|
|
|
|
|
|
)
|
|
|
|
await logErr('呼叫失败', error)
|
|
|
|
await logErr('呼叫失败', error)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -568,6 +593,7 @@ const updateLog = (log: string): void => {
|
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => {
|
|
|
|
onMounted(async () => {
|
|
|
|
sessionState.value = await window.session.get()
|
|
|
|
sessionState.value = await window.session.get()
|
|
|
|
|
|
|
|
await window.mainCallStatus.set(callStatus.value)
|
|
|
|
|
|
|
|
|
|
|
|
// 从 Login.vue 缓存的 appConfig 中读取 selected_win_uid,作为 /getQueueCount 参数来源
|
|
|
|
// 从 Login.vue 缓存的 appConfig 中读取 selected_win_uid,作为 /getQueueCount 参数来源
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
|