Commit 93226274 by liimin

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

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