Ver Fonte

reactor:新增小休审核;

zhangchong há 1 mês atrás
pai
commit
9f26893fcb
1 ficheiros alterados com 70 adições e 23 exclusões
  1. 70 23
      src/layout/navBars/breadcrumb/zgTel.vue

+ 70 - 23
src/layout/navBars/breadcrumb/zgTel.vue

@@ -82,12 +82,19 @@
 			</template>
 
 			<!-- 小休和结束休息 可用 -->
-			<template v-if="m_bLogin && activeArr.includes('rest')">
+			<template v-if="m_bLogin && activeArr.includes('rest') && !isRestAudit">
 				<div class="item active" :title="m_bTelBusy ? '示闲' : '小休'" @click="onEvent(m_bTelBusy ? 'idle' : 'busy')">
 					<SvgIcon name="iconfont icon-rest" class="icon mr3" size="16px" />
 					{{ m_bTelBusy ? '示闲' : '小休' }}
 				</div>
 			</template>
+			<!-- 小休审核中 -->
+			<template v-if="m_bLogin && isRestAudit">
+				<div class="item disabled" title="小休审核中">
+					<SvgIcon name="iconfont icon-rest" class="icon mr3" size="16px" />
+					审核中
+				</div>
+			</template>
 			<!-- 灰色小休不可用 -->
 			<template v-else>
 				<div class="item disabled" title="小休"><SvgIcon name="iconfont icon-rest" class="icon mr3" size="18px" />小休</div>
@@ -330,7 +337,7 @@
 </template>
 
 <script setup lang="ts" name="zgTelControl">
-import { computed, onMounted, reactive, ref } from 'vue';
+import { computed, onBeforeUnmount, onMounted, reactive, ref } from 'vue';
 import { getNowDateTime } from '@/utils/constants';
 import { ElMessage, ElMessageBox, ElNotification, FormInstance } from 'element-plus';
 import { useRouter } from 'vue-router';
@@ -353,6 +360,7 @@ import { submitLog } from '@/api/public/log';
 import { useTransition } from '@vueuse/core';
 import { busyOff, busyOn, telRestBaseData } from '@/api/public/wex';
 import { getSpecialNumberDetailByPhone } from '@/api/auxiliary/specialNumber';
+import signalR from '@/utils/signalR';
 
 const globalState = useGlobalState(); // 全局变量
 const state = reactive<any>({
@@ -397,6 +405,7 @@ const activeArr = computed(() => {
 		'100': [], // 登录成功
 		'200': ['dutyOff', 'rest', 'outbound'], // 空闲
 		'201': ['dutyOff', 'rest', 'outbound'], // 小休
+		'202': ['dutyOff'], // 小休审批中
 		'300': ['hangup'], // 呼入振铃
 		'301': ['hangup', 'hold', 'consult', 'transferMz', 'evaluate'], // 呼入通话
 		'302': ['hangup'], // 呼出振铃
@@ -420,6 +429,7 @@ const currentStatusText = computed(() => {
 		'100': '登录成功',
 		'200': '空闲',
 		'201': '小休',
+		'202': '小休审批中',
 		'300': '呼入振铃',
 		'301': '呼入通话',
 		'302': '呼出振铃',
@@ -1234,6 +1244,7 @@ const retSignOut = () => {
 	}
 	currentWait.value = 0; // 当前等待重置
 	globalState.callCenterWs = null;
+	isRestAudit.value = false; // 重置小休审核状态
 	console.log(`${getNowDateTime()} 呼叫中心签出回调`);
 
 	const objMsg = {
@@ -1298,31 +1309,36 @@ const stopBusyTime = () => {
 };
 const restFormRef = ref<RefType>(); // 小休表单
 const onBusy = () => {
-	// state.restDialogVisible = true;
-	ElMessageBox.confirm(`确定要小休,是否继续?`, '提示', {
-		confirmButtonText: '确认',
-		cancelButtonText: '取消',
-		type: 'warning',
-		draggable: true,
-		cancelButtonClass: 'default-button',
-		autofocus: false,
-	})
-		.then(() => {
-			const objMsg = {
-				Action: 'ReqAgentBusy',
-				Param: {
-					Extension: m_strUserNo.value,
-				},
-			};
-			// 发送请求
-			e_TelSendMsg(objMsg);
+	if (AppConfigInfo.value.isRestApproval) {
+		// 需要小休审批
+		state.restDialogVisible = true;
+	} else {
+		ElMessageBox.confirm(`确定要小休,是否继续?`, '提示', {
+			confirmButtonText: '确认',
+			cancelButtonText: '取消',
+			type: 'warning',
+			draggable: true,
+			cancelButtonClass: 'default-button',
+			autofocus: false,
 		})
-		.catch(() => {
-			state.loading = false;
-		});
+			.then(() => {
+				const objMsg = {
+					Action: 'ReqAgentBusy',
+					Param: {
+						Extension: m_strUserNo.value,
+					},
+				};
+				// 发送请求
+				e_TelSendMsg(objMsg);
+			})
+			.catch(() => {
+				state.loading = false;
+			});
+	}
 };
 // 确认小休
 const restReason = ref(''); // 小休原因
+const isRestAudit = ref(false); // 是否小休审核
 const clickOnRest = (formEl: FormInstance | undefined) => {
 	if (!formEl) return;
 	formEl.validate((valid: boolean) => {
@@ -1337,6 +1353,7 @@ const clickOnRest = (formEl: FormInstance | undefined) => {
 		};
 		// 发送请求
 		e_TelSendMsg(objMsg);
+		isRestAudit.value = true; // 正在小休审核中
 	});
 };
 
@@ -2591,12 +2608,39 @@ const getReason = async () => {
 		console.log(err);
 	}
 };
+// 监听消息
+const signalRStart = () => {
+	signalR?.SR?.on('RestApplyPass', (data: any) => {
+		// 小休审批通过消息
+		console.log(`${getNowDateTime()}:小休审批通过消息`, data);
+		RestApplyPassFn(data);
+	});
+};
+// 小休审批通过消息
+const RestApplyPassFn = (data: any) => {
+	ElNotification({
+		title: '成功',
+		message: '小休审批通过,开始小休',
+		type: 'success',
+	});
+	isRestAudit.value = false;
+	const objMsg = {
+		Action: 'ReqAgentBusy',
+		Param: {
+			Extension: m_strUserNo.value,
+		},
+	};
+	// 发送请求
+	e_TelSendMsg(objMsg);
+	console.log(`${getNowDateTime()}:小休审核通过,${data}`);
+};
 onMounted(async () => {
 	await getBaseInfo(); // 查询可以签入的分机
 	await getThreeWayAndTransfer(); // 查询呼叫转接的号码列表
 	// await getReason(); // 获取小休原因
 	initWs();
 	await checkLogin();
+	signalRStart();
 	// 是否在通话中
 	window.onbeforeunload = function (e: any) {
 		if (m_bCallConnect.value) {
@@ -2606,6 +2650,9 @@ onMounted(async () => {
 		}
 	};
 });
+onBeforeUnmount(() => {
+	signalR.SR.off('RestApplyPass');
+});
 </script>
 
 <style scoped lang="scss">