Commit 4747dbb0 by liimin

refactor(ReceptionCenter): 重构接待记录列表组件,优化代码结构和逻辑

- 使用策略模式重构不同tab页的UI逻辑和数据加载
- 移除未使用的代码和冗余状态
- 添加删除接待记录功能
- 优化列表空状态和加载更多逻辑
- 统一数据加载和状态管理方式
1 parent 32e40361
...@@ -49,16 +49,6 @@ export default { ...@@ -49,16 +49,6 @@ export default {
tabIndex: Number, tabIndex: Number,
userInfo: Object userInfo: Object
}, },
name: '',
data () {
return {
}
},
watch: {
userInfo (n) {
},
},
computed: { computed: {
...mapGetters({ ...mapGetters({
hasTempRecords: 'perRecordNumber' hasTempRecords: 'perRecordNumber'
......
...@@ -85,7 +85,7 @@ export default { ...@@ -85,7 +85,7 @@ export default {
timeProgress: '', timeProgress: '',
tabIndex: 0, tabIndex: 0,
typeList: Object.freeze([ typeList: Object.freeze([
{ tabName: '接待复盘' }, { tabName: '接待记录' },
// { tabName: '客户预录' }, // { tabName: '客户预录' },
]), ]),
showInfo: false, showInfo: false,
......
...@@ -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-30 19:14:28 * @LastEditTime: 2025-12-31 11:38:31
* @FilePath: \simgle_app\utils\recordManager\TempRecord.js * @FilePath: \simgle_app\utils\recordManager\TempRecord.js
*/ */
import utils from '../utils' import utils from '../utils'
...@@ -152,6 +152,29 @@ class TempRecord { ...@@ -152,6 +152,29 @@ class TempRecord {
uni.$logger.local.error('〖接待记录Record〗 == 保存记录异常' + error.message) uni.$logger.local.error('〖接待记录Record〗 == 保存记录异常' + error.message)
} }
} }
/**
* 彻底删除一条接待记录
* - 删除所有已保存的 urlList 文件
* - 删除当前的临时文件 tempFilePath
* - 删除数据库中的记录
* @param {Object} record - 要删除的记录对象
* @returns {Promise<void>}
*/
async deleteRecord(record) {
if (!record) return
uni.$logger.local.warn('〖接待记录Record〗 == 开始彻底删除记录 id: ' + record.id)
// 1. 删除 urlList 中的所有持久化文件
if (record.urlList?.length) {
await this.clearSavedFiles(record)
}
// 2. 删除当前记录的临时文件和数据库记录
// 注意:clearLocalRecord 内部会处理 tempFilePath 的删除和数据库记录的移除
await this.clearLocalRecord(record)
uni.$logger.local.warn('〖接待记录Record〗 == 记录彻底删除完成')
}
async clearLocalRecord(record = this.record) { async clearLocalRecord(record = this.record) {
const { id, tempFilePath } = record || {} const { id, tempFilePath } = record || {}
uni.$logger.local.info('〖接待记录Record〗 == 删除临时文件' + tempFilePath) uni.$logger.local.info('〖接待记录Record〗 == 删除临时文件' + tempFilePath)
...@@ -167,13 +190,16 @@ class TempRecord { ...@@ -167,13 +190,16 @@ class TempRecord {
* 清除已保存的录音文件 * 清除已保存的录音文件
* @param {Object} options - 配置参数 * @param {Object} options - 配置参数
* @param {Array} options.urlList - 录音文件列表,默认为当前记录的urlList * @param {Array} options.urlList - 录音文件列表,默认为当前记录的urlList
* @returns {Promise<void>}
*/ */
clearSavedFiles({ urlList = [] } = this.record) { async clearSavedFiles({ urlList = [] } = this.record) {
// 遍历录音文件列表并删除每个文件 // 遍历录音文件列表并删除每个文件
urlList.forEach(item => { // 使用 Promise.all 确保所有删除操作完成后才返回
const deletePromises = urlList.map(item => {
uni.$logger.local.warn('〖接待记录Record〗 == 清除已保存文件 -> ' + item.file) uni.$logger.local.warn('〖接待记录Record〗 == 清除已保存文件 -> ' + item.file)
this.removeFile(item.file) return this.removeFile(item.file)
}) })
await Promise.all(deletePromises)
} }
/** /**
* 将已保存的文件列表映射为上传列表(统一拼接基础保存路径) * 将已保存的文件列表映射为上传列表(统一拼接基础保存路径)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!