behaviorAnalysis.js
5.23 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import api from '~/api/crew/index'
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/'
Component({
properties: {
detailInfo: {
type: Object,
value: {},
observer: function(n) {
}
},
selectedMerchantObj: {
type: Object
},
merchantList: {
type: Array
},
initTimeDimension: {
type: Number,
value: -1
},
initStartDate: {
type: String,
value: ''
},
initEndDate: {
type: String,
value: ''
}
},
data: {
IMG_URL,
attendanceItems: [
{ label: '打卡天数', key: 'checkInDays' },
{ label: '迟到', key: 'late', valueClass: 'danger' },
{ label: '早退', key: 'earlyLeave', valueClass: 'danger' },
{ label: '旷工', key: 'absenteeism', valueClass: 'danger' }
],
dailyReportItems: [
{ label: '已提交', key: 'submitted', subLabel: '日报完成率', subKey:'completionRate', subClass: 'success' },
{ label: '未提交', key: 'notSubmitted' },
{ label: '在岗', key: 'onDuty' },
{ label: '调休', key: 'rest' }
],
receptionItems: [
{ label: '实际交车数', key: 'actualDelivery' },
{ label: '接待数量', key: 'receptionCount' },
{ label: '未触客数', key: 'notTouched' }
],
weakTags: [
{ label: '身份介绍:差', type: 'danger' },
{ label: '场景塑造:差', type: 'danger' },
{ label: '案例展示:差', type: 'danger' }
],
otherTags: [
{ label: '逼单能力:一般', type: 'default' },
{ label: '话题介入:一般', type: 'default' },
{ label: '攻防能力:一般', type: 'default' },
{ label: '服务意识:一般', type: 'default' },
{ label: '专业知识:好', type: 'success' }
],
recordStatsRows: [
[
{ label: '录音', key: 'recordingCount' },
{ label: '成交数', key: 'dealCount' },
{ label: '战败数', key: 'defeatCount' },
{ label: '成交率', key: 'dealRate' }
],
[
{ label: '质检平均分', key: 'qualityScore' },
{ label: '攻防平均分', key: 'attackDefenseScore' },
{ label: '录音缺失率', key: 'recordingMissingRate' }
]
],
tagRows: [{
label: '弱项',
class: 'danger',
key: 'badList'
}, {
label: '其他项',
key: 'ohterList'
}],
dressWarningItems: [{ label: '预警次数', key: 'warningCount' }],
behaviorInfo: {}
},
methods: {
_beginRequest() {
this._reqSeq = (this._reqSeq || 0) + 1
return this._reqSeq
},
_isLatestRequest(seq) {
return seq === this._reqSeq
},
search(e) {
this.setData({
startStr: e.detail.startDay?.replace(/\//g, '-'),
endStr: e.detail.endDay?.replace(/\//g, '-')
}, () => {
this.getData()
})
this.triggerEvent('datesave', {
scope: 'behaviorAnalysis',
timeDimension: e.detail.timeDimension,
startDate: e.detail.startDay,
endDate: e.detail.endDay
}, { bubbles: true, composed: true })
},
safeObjectToLabelList(obj) {
if (!obj || typeof obj !== 'object') {
return []
}
let cleanObj = {};
try {
const jsonStr = JSON.stringify(obj)
cleanObj = JSON.parse(jsonStr)
} catch (e) {
return []
}
const result = []
try {
const keys = Object.keys(cleanObj)
for (let i = 0; i < keys.length; i++) {
const key = keys[i]
const value = cleanObj[key]
const displayValue = (typeof value === 'object' && value !== null)
? JSON.stringify(value)
: String(value)
result.push(`${key} : ${displayValue}`)
}
} catch (e) {
return []
}
return result
},
getData() {
const seq = this._beginRequest()
let { detailInfo, startStr, endStr, selectedMerchantObj } = this.data
let params = {
phone: detailInfo.employeePhone,
employeeId: selectedMerchantObj?.employeeId,
merchantId: selectedMerchantObj?.merchantId,
bizs: detailInfo.scene,
startDate: startStr,
endDate: endStr
}
wx.$util.showLoading()
api.getEmployeebehaviorData(params).then(res => {
if (!this._isLatestRequest(seq)) return
wx.$util.hideLoading()
let { code, data, message } = res
if (code == 0) {
data.recordingAnalysis.badList = this.safeObjectToLabelList(data.recordingAnalysis.badList)
data.recordingAnalysis.ohterList = this.safeObjectToLabelList(data.recordingAnalysis.ohterList)
this.setData({
behaviorInfo: data
})
} else {
wx.$util.showToast(message)
}
}).catch(() => {
if (!this._isLatestRequest(seq)) return
wx.$util.hideLoading()
})
},
handleChangeMerchant() {
this.triggerEvent('changeMerchant')
},
handleChangeMerchant(e) {
let { merchantList, selectedMerchantObj } = this.data
this.setData({
showSelectPopup: true,
selectOptions: merchantList,
selectValue: selectedMerchantObj.merchantId ? [selectedMerchantObj.merchantId] : []
})
this.triggerEvent('changeMerchant', true)
},
handlePopupConfirm(e) {
let { items } = e.detail
let thisPage = wx.$router.getPageInstance()
thisPage.setData({
selectedMerchantObj: {
merchantId: items[0].merchantId,
merchantName: items[0]?.merchantName,
employeeId: items[0].employeeId
}
}, () => {
this.getData()
})
this.hideSelectPopup()
},
hideSelectPopup() {
this.setData({
showSelectPopup: false
})
this.triggerEvent('changeMerchant', false)
},
},
})