Browse Source

reactor:重构录音播放组件;

zhangchong 7 months ago
parent
commit
f82009dd13

+ 55 - 34
src/components/PlayRecord/index.vue

@@ -13,18 +13,33 @@
 	>
 		<div v-loading="loading">
 			<el-table :data="tableData" border>
-				<el-table-column prop="name" label="来电号码" align="center"/>
-				<el-table-column prop="createTime" label="来电时间" width="160" align="center"/>
-				<el-table-column prop="duration" label="时长" align="center"/>
+				<el-table-column prop="name" label="来电号码" align="center" />
+				<el-table-column prop="createTime" label="来电时间" width="160" align="center" />
+				<el-table-column prop="duration" label="时长" align="center" />
 				<el-table-column prop="size" label="操作" align="center">
 					<template #default="{ row }">
 						<el-button type="primary" link v-auth="'public:record:download'" @click="download(row)">下载</el-button>
 					</template>
 				</el-table-column>
 			</el-table>
-			<audio-player :url="RecordUrl" :key="RecordUrl"/>
+			<audio-player :url="recordUrl" :key="recordUrl" />
+			<audio :src="recordUrl" controls preload="auto" class="w100" v-loading="loading" :key="recordUrl"></audio>
 		</div>
 	</el-dialog>
+	<el-dialog
+		v-model="dialogVisibleSmart"
+		width="600px"
+		draggable
+		title="播放录音"
+		append-to-body
+		destroy-on-close
+		:modal="false"
+		modal-class="modal_class"
+		class="dialog_class_record"
+		:close-on-click-modal="false"
+	>
+		<audio :src="recordUrl" controls preload="auto" class="w100" v-loading="loading" :key="recordUrl"></audio>
+	</el-dialog>
 </template>
 
 <script lang="ts" setup name="playRecord">
@@ -39,7 +54,7 @@ import { storeToRefs } from 'pinia';
 const AudioPlayer = defineAsyncComponent(() => import('@/components/AudioPlayer/index.vue'));
 // 定义子组件向父组件传值/事件
 const emit = defineEmits(['openDialog', 'closeDialog']);
-const RecordUrl = ref<string>(''); //录音地址
+const recordUrl = ref<string>(''); //录音地址
 const dialogVisible = ref<boolean>(false); //是否显示弹窗
 const tableData = ref<EmptyArrayType>([]);
 const loading = ref(false);
@@ -49,24 +64,47 @@ const { themeConfig } = storeToRefs(storesThemeConfig);
 const openDialog = async (callId: string) => {
 	loading.value = true;
 	try {
-		const {result} = await callLogDetail(callId );
+		const { result } = await callLogDetail(callId);
 		tableData.value = [
 			{
-				name:result.fromNo,
+				name: result.fromNo,
 				createTime: formatDate(result.beginIvrTime, 'YYYY-mm-dd HH:MM:SS'),
 				duration: `${result.duration}秒`,
-				...result
-			}
-		]
+				...result,
+			},
+		];
 		dialogVisible.value = true;
 		loading.value = false;
-		RecordUrl.value =  themeConfig.value.recordPrefix+result.audioFile;
+		recordUrl.value = themeConfig.value.recordPrefix + result.audioFile;
 		emit('openDialog');
-	}catch (e){
-		console.log(e)
-		loading.value = true;
+	} catch (e) {
+		console.log(e);
+		loading.value = false;
 	}
-	/*let popup = window.open('', '_blank', 'left=100,top=100,width=400,height=200');
+};
+// 关闭弹窗
+const closeDialog = () => {
+	dialogVisible.value = false;
+	emit('closeDialog');
+};
+// 下载录音
+const download = (row: any) => {
+	loading.value = true;
+	fileDownload({ path: themeConfig.value.recordDownLoadPrefix + row.audioFile })
+		.then((res: any) => {
+			downloadFileByStream(res, row.audioFile);
+			loading.value = false;
+		})
+		.catch(() => {
+			loading.value = false;
+		});
+};
+// 直接打开录音
+const dialogVisibleSmart = ref(false);
+const playRecord = (url: string) => {
+	recordUrl.value = url;
+	dialogVisibleSmart.value = true;
+	/*	let popup = window.open('', '_blank', 'left=100,top=100,width=400,height=200');
 	if (popup) {
 		popup.document.write(`
         <html>
@@ -119,24 +157,8 @@ const openDialog = async (callId: string) => {
 		alert('浏览器阻止了弹出窗口,请允许弹出窗口后再试。');
 	}*/
 };
-// 关闭弹窗
-const closeDialog = () => {
-	dialogVisible.value = false;
-	emit('closeDialog');
-};
-// 下载录音
-const download = (row:any)=>{
-	console.log(row,'111')
-	loading.value = true;
-	fileDownload({ path: themeConfig.value.recordDownLoadPrefix + row.audioFile }).then((res: any) => {
-		downloadFileByStream(res, row.audioFile);
-		loading.value = false;
-	}).catch(()=>{
-		loading.value = false;
-	})
-};
 //暴漏变量和方法
-defineExpose({ closeDialog, openDialog });
+defineExpose({ closeDialog, openDialog, playRecord });
 </script>
 <style lang="scss" scoped>
 .item {
@@ -160,7 +182,6 @@ defineExpose({ closeDialog, openDialog });
 	margin: 0 !important;
 	position: absolute;
 	top: 30vh;
-	left:calc(50vw - 300px);
+	left: calc(50vw - 300px);
 }
 </style>
-

+ 0 - 26
src/views/business/visit/component/Smart-visit-Detail.vue

@@ -52,7 +52,6 @@ import { useThemeConfig } from '@/stores/themeConfig';
 import { storeToRefs } from 'pinia';
 
 const OrderDetail = defineAsyncComponent(() => import('@/components/OrderDetail/index.vue')); // 工单详情
-const PlayRecord = defineAsyncComponent(() => import('@/views/tels/callLog/component/Play-record.vue')); // 播放录音
 const state = reactive({
 	queryParams: {
 		// 查询条件
@@ -126,7 +125,6 @@ const columns = ref<any[]>([
 		label: '处理结果',
 		prop: 'volved',
 	},
-	// { prop: 'operation', label: '操作', fixed: 'right', width: 160, align: 'center' },
 ]);
 // 页面基础数据
 const aiOrderVisitState = ref([]);
@@ -173,30 +171,6 @@ const close = () => {
 	queryParamsRef.value?.resetFields();
 	queryParamsRef.value?.resetFields();
 };
-// 播放录音
-const playRecordRef = ref<RefType>();
-const storesThemeConfig = useThemeConfig();
-const { themeConfig } = storeToRefs(storesThemeConfig);
-const onPlaySoundRecording = (val: any) => {
-	playRecordRef.value.openDialog(themeConfig.value.recordPrefix + val.recordingAbsolutePath);
-};
-// 下载录音
-const onDownload = (row: any) => {
-	ElMessageBox.confirm(`您确定要下载此录音吗?`, '提示', {
-		confirmButtonText: '确认',
-		cancelButtonText: '取消',
-		type: 'warning',
-		draggable: true,
-		cancelButtonClass: 'default-button',
-		autofocus: false,
-	})
-		.then(() => {
-			fileDownload({ path: themeConfig.value.recordDownLoadPrefix + row.recordingAbsolutePath }).then((res: any) => {
-				downloadFileByStream(res, row.recordingFileName);
-			});
-		})
-		.catch(() => {});
-};
 // 重置所有工单列表
 const queryParamsRef = ref<RefType>();
 const resetQuery = (formEl: FormInstance | undefined) => {

+ 5 - 10
src/views/business/visit/component/Visit-detail.vue

@@ -78,7 +78,7 @@
 										size="small"
 										type="primary"
 										class="ml8"
-										@click="recordFile(state)"
+										@click="recordFile"
 										v-if="state.recordingAbsolutePath"
 										>人工回访录音</el-button
 									>
@@ -450,11 +450,10 @@ import dayjs from 'dayjs';
 import { visitDetailBaseData, visitOrder } from '@/api/business/visit';
 import mittBus from '@/utils/mitt';
 import { callCenterOutbound } from '@/utils/callCenter';
-import { useThemeConfig } from '@/stores/themeConfig';
 
 // 引入组件
 const CommonAdvice = defineAsyncComponent(() => import('@/components/CommonAdvice/index.vue')); // 常用意见
-const PlayRecord = defineAsyncComponent(() => import('@/views/tels/callLog/component/Play-record.vue')); // 播放录音
+const PlayRecord = defineAsyncComponent(() => import('@/components/PlayRecord/index.vue')); // 播放录音
 // 定义子组件向父组件传值/事件
 const emit = defineEmits(['updateList']);
 // 定义变量内容
@@ -580,16 +579,12 @@ const closeDialog = () => {
 };
 // 查看人工回访录音文件
 const playRecordRef = ref<RefType>();
-const storesThemeConfig = useThemeConfig();
-const { themeConfig } = storeToRefs(storesThemeConfig);
-const recordFile = (obj: any) => {
-	const fileName = `工单编号-${obj.orderDetail?.no} 人工回访录音文件`;
-	playRecordRef.value.openDialog(themeConfig.value.recordPrefix + obj.recordingAbsolutePath, fileName, obj.recordingAbsolutePath);
+const recordFile = () => {
+	playRecordRef.value.openDialog(state.orderDetail.callId)
 };
 // 查看智能回访录音
 const onSmartRecord = () => {
-	const fileName = `工单编号-${state.orderDetail?.no} 智能回访录音文件`;
-	playRecordRef.value.openDialog(aiVisitVoiceBaseUrl.value + state.smartRecord, fileName);
+	playRecordRef.value.playRecord(aiVisitVoiceBaseUrl.value + state.smartRecord);
 };
 // 呼叫
 const onCall = (phoneNumber: string) => {

+ 4 - 6
src/views/quality/done/components/Quality-inspection.vue

@@ -181,7 +181,7 @@
 	<play-record ref="playRecordRef" />
 </template>
 <script setup lang="ts" name="qualityInspection">
-import { computed, reactive, ref, watch, defineAsyncComponent } from 'vue';
+import { reactive, ref, watch, defineAsyncComponent } from 'vue';
 import { ElMessage, ElMessageBox, FormInstance } from 'element-plus';
 import { formatDate, formatDuration } from '@/utils/formatTime';
 import Other from '@/utils/other';
@@ -191,7 +191,7 @@ import { useThemeConfig } from '@/stores/themeConfig';
 import { storeToRefs } from 'pinia';
 
 // 引入组件
-const PlayRecord = defineAsyncComponent(() => import('@/views/tels/callLog/component/Play-record.vue')); // 播放录音
+const PlayRecord = defineAsyncComponent(() => import('@/components/PlayRecord/index.vue')); // 播放录音
 // 定义子组件向父组件传值/事件
 const emit = defineEmits(['updateList']);
 const state = reactive<any>({
@@ -309,12 +309,10 @@ const { themeConfig } = storeToRefs(storesThemeConfig);
 const recordFile = (obj: any, type: string) => {
 	switch (type) {
 		case 'order':
-			const fileName = `工单编号-${obj.no} 录音文件`;
-			playRecordRef.value.openDialog(themeConfig.value.recordPrefix + obj.recordingAbsolutePath, fileName, obj.recordingAbsolutePath);
+			playRecordRef.value.openDialog(obj.callId);
 			break;
 		case 'visit':
-			const fileNames = `工单编号-${obj.order?.no} 录音文件`;
-			playRecordRef.value.openDialog(themeConfig.value.recordPrefix + obj.recordingAbsolutePath, fileNames, obj.recordingAbsolutePath);
+			playRecordRef.value.playRecord(themeConfig.value.recordPrefix + obj.recordingAbsolutePath);
 			break;
 	}
 };

+ 3 - 5
src/views/quality/index/components/Quality-inspection.vue

@@ -190,7 +190,7 @@ import { useThemeConfig } from '@/stores/themeConfig';
 import { storeToRefs } from 'pinia';
 
 // 引入组件
-const PlayRecord = defineAsyncComponent(() => import('@/views/tels/callLog/component/Play-record.vue')); // 播放录音
+const PlayRecord = defineAsyncComponent(() => import('@/components/PlayRecord/index.vue')); // 播放录音
 // 定义子组件向父组件传值/事件
 const emit = defineEmits(['updateList']);
 const state = reactive<any>({
@@ -303,12 +303,10 @@ const { themeConfig } = storeToRefs(storesThemeConfig);
 const recordFile = (obj: any, type: string) => {
 	switch (type) {
 		case 'order':
-			const fileName = `工单编号-${obj.no} 录音文件`;
-			playRecordRef.value.openDialog(themeConfig.value.recordPrefix + obj.recordingAbsolutePath, fileName, obj.recordingAbsolutePath);
+			playRecordRef.value.openDialog(obj.callId);
 			break;
 		case 'visit':
-			const fileNames = `工单编号-${obj.order?.no} 录音文件`;
-			playRecordRef.value.openDialog(themeConfig.value.recordPrefix + obj.recordingAbsolutePath, fileNames, obj.recordingAbsolutePath);
+			playRecordRef.value.playRecord(themeConfig.value.recordPrefix + obj.recordingAbsolutePath);
 			break;
 	}
 };

+ 1 - 1
src/views/statistics/call/detailIndexCall.vue

@@ -124,7 +124,7 @@ const playRecordRef = ref<RefType>();
 const storesThemeConfig = useThemeConfig();
 const { themeConfig } = storeToRefs(storesThemeConfig);
 const onPlaySoundRecording = (val: any) => {
-	playRecordRef.value.openDialog(themeConfig.value.recordPrefix + val.recordingAbsolutePath,val.recordingAbsolutePath);
+	playRecordRef.value.openDialog(val.otherAccept);
 };
 // 下载录音
 const onDownload = (row: any) => {

+ 1 - 1
src/views/tels/callLog/ybCallLog.vue

@@ -1014,7 +1014,7 @@ const playRecordRef = ref<RefType>();
 const storesThemeConfig = useThemeConfig();
 const { themeConfig } = storeToRefs(storesThemeConfig);
 const onPlaySoundRecording = (val: any) => {
-	playRecordRef.value.openDialog(val.id);
+	playRecordRef.value.openDialog(val.otherAccept);
 };
 // 下载录音
 const onDownload = (row: any) => {

+ 0 - 3
src/views/tels/smartRecord/index.vue

@@ -120,9 +120,6 @@ import { fileDownload } from '@/api/public/file';
 import { olaFn } from '@/utils/olaFn';
 
 
-// 引入组件
-const PlayRecord = defineAsyncComponent(() => import('@/views/tels/callLog/component/Play-record.vue')); // 播放录音
-
 const proTableRef = ref<RefType>(); // 表格ref
 // 表格配置项
 const columns = ref<any[]>([