Commit d771688d by liimin

feat(质检模块): 优化质检数据加载状态处理及排序逻辑

- 新增质检数据加载状态显示,提升用户体验
- 修复质检数据排序问题,统一使用时间倒序排列
- 优化对话详情解析逻辑,增加异常处理
- 添加空记录保存时的校验提示
- 重构接待记录列表排序方法,提高代码复用性
1 parent 39eacbea
......@@ -236,64 +236,31 @@ export default {
},
jumpDetail (item) {
// item = {
// "id": null,
// "merchantId": "44210895",
// customerType: 'VIP',
// "customerName": "1211第五",
// "phoneNumber": "13512110555",
// "salesUuid": "77936e318e9844e4af0b099c7ccc98e4",
// "salesName": "叶立庆",
// "carBrandId": null,
// "carBrand": "AITO 问界",
// "carModel": "问界M8",
// "receptionStartTime": 1765447430000,
// "receptionEndTime": 1765449405000,
// "recordUrlList": null,
// "recCustomerId": null,
// "loginPhone": null,
// "receptionStatus": 0,
// "endReasonType": null,
// "staffUuid": "9ec5c68f73e84357a427da9503a5ee8b",
// "staffName": null,
// "serviceMerchantId": null,
// "receptionCustomerPaySourceList": null,
// "orderFlag": null,
// "bussinessType": null,
// "channelType": null,
// "appCode": null,
// "appVersion": null,
// "merchantName": "波波的单店门店",
// "customerVisitId": null,
// "receptionCustomerMaterialPointList": null,
// "carPurchaseMethod": null,
// "checkHistoryFlag": 0,
// "batchId": 72,
// "score": 35,
// "recordingUrl": "https://glsk-oss.oss-cn-shenzhen.aliyuncs.com/quality/176544865331017654474319060.mp3",
// "recordId": null,
// "recordingTagRelationList": null,
// "sfjs": null,
// "fwys": null,
// "htjr": null,
// "sqfx": null,
// "zyzs": null,
// "cjsz": null,
// "alzs": null,
// "gfnl": null,
// "bdnl": null,
// "reviewFlag": null,
// "oneCarBrand": "鸿蒙智行",
// "oneCarBrandId": null,
// "bussinessTypeName": null,
// "checkDate": null,
// "isOrderFinishFlagName": "0",
// "modelType": "1001",
// "checkType": 1,
// "orderFinishFlag": false,
// "duration": "32分55秒",
// "startTime": "2025.12.11 18:03:50",
// "endTime": "2025.12.11 18:36:45",
// "totalDuration": 1975
// carType: "1001",
// createBy: null,
// createById: null,
// createTime: "2026-01-05 09:17:54",
// customerName: "放地方",
// customerPhone: "13476670746",
// customerType: "地方编码",
// duration: "1352",
// durationStr: "22分32秒",
// endTime: "2026-01-05 10:42:43",
// id: "71",
// materialId: "0",
// merchantId: "0",
// receptionDate: "2026-01-05",
// recordUrl: "https://report-default-test.oss-cn-shenzhen.aliyuncs.com/2026/01/06/b9dae32a-ee28-4dd5-9a69-f7f6462a9db4.mp3",
// remark: null,
// result: "string",
// score: 67,
// startTime: "2026-01-05 10:20:11",
// typeCode: "RECEPTION_TYPE_001",
// updateBy: null,
// updateById: null,
// updateTime: "2026-01-06 09:18:01",
// userId: "4454545",
// userName: "池师傅"
// }
if (this.tabIndex == 0) { // 已上传 && 新质检
// const { sceneType } = uni.$storage.get("userInfo");
......@@ -315,9 +282,19 @@ export default {
}
},
// 工具方法:按时间倒序排序
sortByTime(list, key = 'startTime') {
if (!Array.isArray(list)) return []
return list.sort((a, b) => {
const timeA = new Date(a[key]).getTime()
const timeB = new Date(b[key]).getTime()
return timeB - timeA
})
},
async loadRecords () {
let records = await uni.$dbRecord.getRecords();
this.recordList = records.reverse();
this.recordList = this.sortByTime(records);
},
async loadTempRecords () {
if (!this.recorder) {
......@@ -351,7 +328,7 @@ export default {
await this.loadTempRecords()
// 这里的 tempRecordList 是一个数组,我们需要创建一个新数组来触发 reverse,避免修改原数组(虽然这里修改原数组也没大碍)
// 关键:确保 formattedList 是一个数组
const formattedList = [...this.tempRecordList].reverse()
const formattedList = this.sortByTime([...this.tempRecordList])
// 修复 Vue2 响应式问题
// 确保 list[0] 被正确设置
this.$set(this.list, 0, formattedList)
......@@ -403,7 +380,8 @@ export default {
}) || {}
// 3. 数据处理
records.reverse().forEach(e => {
const sortedRecords = this.sortByTime(records)
sortedRecords.forEach(e => {
e.duration = e.durationStr || this.formatSeconds(new Date(e.endTime).getTime() - new Date(e.startTime).getTime())
e.orderFinishFlag = e.result === '完成' ? 1 : 0
})
......@@ -411,12 +389,12 @@ export default {
// 4. 更新缓存 (仅第一页)
if (pageNum === 1) {
const cache = JSON.parse(uni.$storage.get("recordSuccessList") || "{}")
cache[tabIndex] = records
cache[tabIndex] = sortedRecords
uni.$storage.set("recordSuccessList", JSON.stringify(cache))
}
// 5. 更新视图
this.$set(this.list, pageNum - 1, records)
this.$set(this.list, pageNum - 1, sortedRecords)
this.total = total
},
......
......@@ -9,7 +9,13 @@
@touchstart="touchstart"
@touchend="touchend"
>
<template v-if="dialogueList.length">
<template v-if="loading">
<view class="nothing flex">
<view class="sprite-icon icon-quality-no-data"></view>
分析中,稍等...
</view>
</template>
<template v-else-if="dialogueList.length">
<block
v-for="(item,index) in dialogueList"
:key="index"
......@@ -70,7 +76,7 @@
<template v-else>
<view class="nothing flex">
<view class="sprite-icon icon-quality-no-data"></view>
分析中,稍等...
暂无对话数据
</view>
</template>
</scroll-view>
......@@ -172,7 +178,8 @@ export default {
isPlayIng: false,
isScrolllIng: false,
toId: '',
touchTimer: null
touchTimer: null,
loading: false
}
},
mounted () {
......@@ -193,20 +200,33 @@ export default {
i.detailClassName = i.detailClassName == 'up' ? 'down' : 'up'
},
async findConversationDetailByBatchIdNew (params) {
const res = await uni.$api.reception.findConversationDetailByReceptionId(params)
res.map(e => {
e.time = this.formatTime(e.mergedOffset)
e.text_id = `text_${e.mergedOffset}`
if (e?.recordingCheckResultList && e.recordingCheckResultList.length) {
e.recordingCheckResultList.map(i => {
i.detailClassName = 'down'
let [scriptRec] = JSON.parse(i.scriptRec)
if (scriptRec) i.scriptRec = scriptRec.replace(/\n/g, '<br>')
else i.scriptRec = ''
})
}
})
this.dialogueList = res
this.loading = true
try {
const res = await uni.$api.reception.findConversationDetailByReceptionId(params)
res.map(e => {
e.time = this.formatTime(e.mergedOffset)
e.text_id = `text_${e.mergedOffset}`
if (e?.recordingCheckResultList && e.recordingCheckResultList.length) {
e.recordingCheckResultList.map(i => {
i.detailClassName = 'down'
if (i.scriptRec){
try {
let [scriptRec] = JSON.parse(i.scriptRec)
if (scriptRec) i.scriptRec = scriptRec.replace(/\n/g, '<br>')
} catch (error) {
i.scriptRec = ''
}
}
else i.scriptRec = ''
})
}
})
this.dialogueList = res
} catch (e) {
uni.$logger.error(e.message)
} finally {
this.loading = false
}
},
async findCbByBatchId () {
let data = JSON.parse(JSON.stringify(this.qualityData))
......@@ -227,7 +247,7 @@ export default {
data.filter(e => e.offset != null)
.sort((a, b) => a.offset - b.offset)
.forEach(e => {
const mergedOffset = e.offset / 1000
const mergedOffset = e.offset
let top = mergedOffset / totalDuration * containerHeight
e.docTop = top
e.text_id = `text_${mergedOffset}`
......
<template>
<view class="view">
<template v-if="qualityData.length">
<template v-if="loading">
<view class="nothing flex">
<view class="sprite-icon icon-quality-no-data"></view>
分析中,稍等...
</view>
</template>
<template v-else-if="qualityData.length">
<view class="classify-wrap">
<template v-for="(item,index) in qualityData">
<view
......@@ -63,7 +69,7 @@
<template v-else>
<view class="nothing flex">
<view class="sprite-icon icon-quality-no-data"></view>
分析中,稍等...
暂无质检数据
</view>
</template>
</view>
......@@ -85,7 +91,11 @@ export default {
type: Boolean,
default: false
},
disabledText: String
disabledText: String,
loading: {
type: Boolean,
default: false
}
},
data () {
return {
......
......@@ -54,14 +54,20 @@
</view>
</view>
<view class="reception-right-box">
<template v-if="qualityData.length">
<template v-if="qualityLoading">
<view class="nothing flex">
<view class="sprite-icon icon-quality-no-data"></view>
分析中,稍等...
</view>
</template>
<template v-else-if="qualityData.length">
<tags :tags="tags" />
<quality-table :qualityData="qualityData" />
</template>
<template v-else>
<view class="nothing flex">
<view class="sprite-icon icon-quality-no-data"></view>
分析中,稍等...
暂无质检数据
</view>
</template>
</view>
......@@ -114,21 +120,23 @@ export default {
status: 'pause',
isOperate: true,
showPlayControl: false,
tags: []
tags: [],
qualityLoading: false
}
},
onLoad (options) {
let _this = this
this.getOpenerEventChannel().on('getData', function (data) {
//计算时长 单位秒
try {
data.receptionStartTime = (dayjs(data.startTime).valueOf())/1000
data.receptionEndTime = (dayjs(data.endTime).valueOf())/1000
data.totalDuration = (data.receptionEndTime - data.receptionStartTime)
data.batchId = data.id = '72'
_this.pageData = Object.freeze(data || {})
if (data.batchId) _this.findCheckResultListByReceptionId(data.batchId)
_this.setAudio(data.recordUrl)
this.getOpenerEventChannel().on('getData', function (params) {
try {
let data = utils.deepClone(params || {})
//计算时长 单位秒
data.receptionStartTime = (dayjs(data.startTime).valueOf())/1000
data.receptionEndTime = (dayjs(data.endTime).valueOf())/1000
data.totalDuration = (data.receptionEndTime - data.receptionStartTime)
data.batchId = data.id
_this.pageData = Object.freeze(data || {})
if (data.batchId) _this.findCheckResultListByReceptionId(data.batchId)
_this.setAudio(data.recordUrl)
} catch (err) {
uni.$logger.local.error('setAudio error'+err.message)
}
......@@ -247,7 +255,7 @@ export default {
__formatScore(item) {
const score = (item.score !== null && item.score !== undefined) ? item.score : '-'
const sumScore = (item.sumScore !== null && item.sumScore !== undefined) ? item.sumScore : '-'
item.__formatScore = `${score}/${sumScore}`
item.formatScore = `${score}/${sumScore}`
},
// 处理命中话术
......@@ -302,6 +310,7 @@ export default {
},
async findCheckResultListByReceptionId (receptionId) {
this.qualityLoading = true
try {
const res = await uni.$api.reception.findCheckResultListByReceptionId({
receptionId
......@@ -330,6 +339,8 @@ export default {
this.qualityData = Object.freeze(res)
} catch (err) {
console.error('findCheckResultListByReceptionId error', err)
} finally {
this.qualityLoading = false
}
},
desensitizePhoneNumber (customerPhone) {
......
// store/plugins/activityTracker.js
import utils from '@/utils/utils'
/**
* 自动监听用户活跃状态的 Vuex 插件
* 当指定的 mutation 发生时,触发 reset_timeout 事件
*/
export default function createActivityTracker(mutationsToWatch = []) {
// 使用 utils.throttle 限制触发频率,避免高频 mutation 导致过多 emit
const notifyActivity = utils.throttle(() => {
uni.$emit('reset_timeout')
}, 1000)
return store => {
store.subscribe((mutation, state) => {
// 如果 mutation 在监控列表中,则触发活跃通知
if (mutationsToWatch.includes(mutation.type)) {
notifyActivity()
}
})
}
}
......@@ -4,7 +4,7 @@
* @Author: limin
* @Date: 2025-01-02 18:49:17
* @LastEditors: limin
* @LastEditTime: 2026-01-05 17:25:50
* @LastEditTime: 2026-01-08 09:12:15
* @FilePath: \simgle_app\utils\recordManager\TempRecord.js
*/
import utils from '../utils'
......@@ -398,6 +398,10 @@ class TempRecord {
* @returns - 返回保存后的文件路径
*/
async saveTempFile(record = this.record) {
if (!record) {
uni.$logger.local.warn('〖接待记录Record〗 == saveTempFile 记录为空,跳过')
return
}
let { tempFilePath, urlList } = record
if (!tempFilePath || urlList.length === 0) {
if (!this.timer) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!