Commit 93226274 by liimin

fix: 修复录音管理和接待记录相关的问题

- 将部分日志级别从info调整为warn以提高可见性
- 修复录音状态判断逻辑,使用recording替代homeRef.audioManager.isRecording
- 增加接待状态检查函数isReceptioning
- 优化未操作超时日志显示,添加分钟数信息
- 修复TempRecord中clearSavedFiles的空记录处理
- 调整代码格式和日志信息
1 parent 9d25c711
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-12-26 10:03:54
* @LastEditors: limin
* @LastEditTime: 2025-12-24 19:29:52
* @LastEditTime: 2025-12-25 09:14:06
* @FilePath: \simgle_app\mixin\record\recorder.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -49,7 +49,7 @@ export default {
handler(val) {
this.handler(val, this.updateReceptionStatus)
}
},
}
// receptionKey: {
// handler(val) {
// this.handler(this.receptionTrack, this.updateMaterialPointList)
......@@ -70,7 +70,7 @@ export default {
try {
const isPermission = await this.checkBeforeStart()
if (!isPermission) return
uni.$logger.local.info('〖接待管理Recorder〗 == 开始接待 ')
uni.$logger.local.warn('〖接待管理Recorder〗 == 开始接待 ')
isInitData && this.initReception()
this.initTime()
this.audioManager.start()
......@@ -95,10 +95,10 @@ export default {
},
async onAudioStop() {
if (this.audioManager.isRecording) {
uni.$logger.local.info('〖接待管理Recorder〗 == 接待中,再次开启录音! ')
uni.$logger.local.warn('〖接待管理Recorder〗 == 接待中,再次开启录音! ')
this.audioManager.start()
} else {
uni.$logger.local.info('〖接待管理Recorder〗 == 断开录音! ')
uni.$logger.local.warn('〖接待管理Recorder〗 == 断开录音! ')
}
},
onAudioError(error) {
......@@ -111,6 +111,10 @@ export default {
* @returns {void}
*/
async stopAudio(isNotSave = false) {
if (!this.isReceptioning()) {
uni.$logger.local.warn('〖接待管理Recorder〗 == 未开始接待,不能结束接待! ')
return
}
uni.$logger.local.info('〖接待管理Recorder〗 == 结束接待! ')
this.stop()
try {
......@@ -122,7 +126,7 @@ export default {
},
async saveAndClearRecord(isNotSave = false) {
if (isNotSave) {
uni.$logger.local.info('〖接待管理Recorder〗 == 不保存记录! ')
uni.$logger.local.warn('〖接待管理Recorder〗 == 不保存记录! ')
this.record.clearSavedFiles()
this.record.clearLocalRecord()
return
......@@ -138,10 +142,13 @@ export default {
this.audioManager?.stop()
},
handler(params, fn) {
if (this.audioManager.isRecording || this.record?.currentRecord?.endReasonType == 1) {
if (this.isReceptioning()) {
fn.call(this, params)
}
},
isReceptioning() {
return this.audioManager?.isRecording || this.record?.currentRecord?.endReasonType == 1
},
reset() {
this.audioManager = null
this.record = null
......@@ -149,7 +156,9 @@ export default {
},
async initDto() {
const userInfo = storageApi.getUserInfo() || {}
const { user:{userId,userName,deptId} } = userInfo
const {
user: { userId, userName, deptId }
} = userInfo
const machineCode = await utils.getOAID()
const dto = new RecordDto({
userId,
......
......@@ -450,7 +450,7 @@ export default {
const serverPaths = uploadedFiles.map(i => i.file)
const localPaths = uploadedFiles.map(i => i.filePathOnClient)
uni.$logger.local.info(`【上传管理Uploader】 == 本条接待所有文件已经上传和处理完毕!!`)
uni.$logger.local.warn(`【上传管理Uploader】 == 本条接待所有文件已经上传和处理完毕!!`)
uni.$logger.local.info(`【上传管理Uploader】 == 已上传的文件: ${JSON.stringify(serverPaths)}`)
// 2. 准备提交参数
......@@ -463,7 +463,7 @@ export default {
// 3. 提交到服务器
uni.$logger.local.info(`【上传管理Uploader】 == 开始向服务器保存接待记录!!参数: ${JSON.stringify(params)}`)
const res = await uni.$api.reception.save(params)
uni.$logger.local.info(`【上传管理Uploader】 == 服务器返回结果: ${JSON.stringify(res)}`)
uni.$logger.local.warn(`【上传管理Uploader】 == 服务器返回结果: ${JSON.stringify(res)}`)
// 4. 清理本地数据
if (res?.code == 200) {
await this._removeRecordFiles(localPaths)
......
......@@ -2,7 +2,7 @@
* @Author: 前端 qianduan01@didihu.com.cn
* @Date: 2024-04-08 11:28:48
* @LastEditors: limin
* @LastEditTime: 2025-12-22 16:41:32
* @LastEditTime: 2025-12-25 09:19:58
* @FilePath: \simgle_app\mixin\timeout.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
......@@ -22,7 +22,7 @@ export default {
if (typeof this.stop === 'function') {
this.stop()
}
uni.$logger.local.info('== 长时间未触碰平板断开录音 ==')
uni.$logger.local.info(`==${TIMER_DURATION / 60000} 分钟未触碰平板断开录音 ==`)
},
//监听点击事件
initTime() {
......@@ -31,15 +31,15 @@ export default {
this.__counter = 0
this.__timer = null
this.__timer = setInterval(() => {
uni.$logger.local.info('== 未触碰平板计时 ==' + this.__counter + '分钟' + '== __timer:' + this.__timer)
if (this.__counter >= TIMER_TIMEOUT) {
//关闭录音
uni.$logger.local.info('== 长时间未触碰平板 == __timer:' + this.__timer + '__counter:' + this.__counter + '分钟')
uni.$logger.local.info(`== ${TIMER_DURATION / 60000} 分钟未触碰平板 == __timer:${this.__timer} __counter:${this.__counter}分钟`)
this.endWatchClick()
this.stopRecorder()
return
}
this.__counter++
uni.$logger.local.info('== 未触碰平板计时 ==' + this.__counter + '分钟' + '== __timer:' + this.__timer)
}, TIMER_INTERVAL)
},
endWatchClick() {
......
......@@ -180,7 +180,7 @@ export default {
icon: 'none'
})
const isPermision = await this.homeRef.isPermission()
if (this.homeRef.audioManager.isRecording || !isPermision) return
if (this.recording || !isPermision) return
const material = this.moduleList[0]
this.setMaterial(material)
// uni.showLoading({
......@@ -191,7 +191,7 @@ export default {
this.id = +material.id
// this.id = 6
this.type = 'edit'
// this.recording = true
this.recording = true
// setTimeout(() => {
// uni.hideLoading()
// }, 1e3)
......@@ -214,8 +214,8 @@ export default {
// 完成接待
done (e) {
this.finishRef.close()
if (this.homeRef.audioManager.isRecording) this.homeRef.stopAudio()
// this.recording = false
if (this.recording) this.homeRef.stopAudio()
this.recording = false
setTimeout(() => {
this.id = ''
this.type = ''
......@@ -232,13 +232,13 @@ export default {
this.backHome()
},
backHome () {
if (this.homeRef.audioManager.isRecording) this.homeRef.stopAudio(true)
if (this.recording) this.homeRef.stopAudio(true)
this.finishRef.close()
this.id = ''
this.type = ''
this.clearHistory()
// this.init()
// this.recording = false
this.recording = false
// this.$refs.home.$refs.leftBox.getMessageInfo()
},
nextStep () {
......
......@@ -4,7 +4,7 @@
* @Author: limin
* @Date: 2025-01-02 18:49:17
* @LastEditors: limin
* @LastEditTime: 2025-12-24 19:28:04
* @LastEditTime: 2025-12-25 09:07:31
* @FilePath: \simgle_app\utils\recordManager\TempRecord.js
*/
import utils from '../utils'
......@@ -107,7 +107,7 @@ class TempRecord {
uni.$logger.local.info('〖接待记录Record〗 == 开始持久化记录 ==' + JSON.stringify(record))
this.clearLoopTimer()
await this.saveTempFile(record)
const { urlList, tempFilePath, ...__record } = record
const { urlList, tempFilePath, endReasonType, ...__record } = record
const recordLongList = await this.__analysisUrlList(urlList)
const { maxUploadNum = 10 } = uni.$storage.get('mock_data')
if (recordLongList.length > maxUploadNum) {
......@@ -149,7 +149,7 @@ class TempRecord {
* @param {Object} options - 配置参数
* @param {Array} options.urlList - 录音文件列表,默认为当前记录的urlList
*/
clearSavedFiles({ urlList = [] } = this.record) {
clearSavedFiles({ urlList = [] } = this.record || {}) {
// 遍历录音文件列表并删除每个文件
urlList.forEach(item => {
uni.$logger.local.info('〖接待记录Record〗 == 清除已保存文件 -> ' + item.file)
......@@ -201,7 +201,7 @@ class TempRecord {
this.addAudio()
}
reset() {
this._isDestroyed = false
this._isDestroyed = false
}
/**
* 构造一条新的接待记录的初始对象
......@@ -443,7 +443,7 @@ class TempRecord {
uni.$logger.local.info('〖接待记录Record〗 == 轮询已启动,跳过')
return
}
if(this._isDestroyed) {
if (this._isDestroyed) {
uni.$logger.local.warn('〖接待记录Record〗 == 组件已销毁,忽略 startSaveAudioLoop')
return
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!