skilled.js
2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// packageEquity/pages/aiCheck/result/components/skilled/skilled.js
import {
skilledEmoji,
familiarList
} from '../../../contant'
Component({
/**
* 组件的属性列表
*/
properties: {
detailInfo: {
type: Object,
observer: function (n) {
this.initData(n)
}
},
scrollTop: {
type: Number,
observer: function (n) {
this.setFixed(n>10)
}
},
avatar: String
},
/**
* 组件的初始数据
*/
data: {
familiarList,
emojiList: skilledEmoji,
level: 3,
star: 3,
sort: ['接待环节', '车辆交付', '需求挖掘', '促成交'],
list: []
},
/**
* 组件的方法列表
*/
methods: {
setFixed(isFixed) {
},
initData(n) {
let data = n.inspectionConversationCheck
data.aiSparringCheckDetailDTOList.forEach(item => {
item.stage = item.stage.slice(0, 4)
if (item.stage == '结束环节') {
item.stage = '促成交'
}
item.conversationDetailList = []
data.conversationDetailList.forEach(con => {
con.suggestions = con.suggestions ? con.suggestions.replace(/<\/br>/g, '\n') : ''
if (con.suggestions == '-') con.suggestions = ''
if (con.detailList && con.detailList.length) {
con.detailList.forEach(detail => {
detail.time = this.formatTime(detail.mergedOffset)
if (detail.id == con.detail.id) {
detail.hit = true
detail.isdown = false
}
})
}
con.firstClassify = con.firstClassify.slice(0, 4)
if (con.firstClassify == '结束环节') {
con.firstClassify = '促成交'
}
if (con.firstClassify.indexOf(item.stage) != -1) {
item.conversationDetailList.push(con)
}
})
})
this.setData({
list: data.aiSparringCheckDetailDTOList,
// isShow:true
}, () => {
this.handleSort()
})
},
handleSort() {
let {
list,
sort
} = this.data;
list.sort((a, b) => {
// 找到a和b在predefinedOrder中的索引
let indexA = sort.indexOf(a.stage);
let indexB = sort.indexOf(b.stage);
// 如果索引相同,则元素相等,返回0
if (indexA === indexB) {
return 0;
}
// 如果a的索引小于b的索引,则a应该排在b前面,返回-1
if (indexA < indexB) {
return -1;
}
// 否则,b应该排在a前面,返回1
return 1;
});
this.setData({
list
})
},
formatTime(num) {
let minutes = Math.floor(num / 60) || '0',
seconds = num % 60 || '0'
seconds = seconds < 10 ? `0${seconds}` : seconds
return `${minutes}:${seconds}`
},
}
})