trainingExperience.js
3.28 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
const IMG_URL = 'https://img02.glsx.com.cn/weapp/resource/miniprogram/supervisor-miniprogram/'
import dayjs from 'dayjs'
import api from '~/api/crew/index'
Component({
properties: {
detailInfo: {
type: Object,
value: {},
},
initTimeDimension: {
type: Number,
value: -1
},
initStartDate: {
type: String,
value: ''
},
initEndDate: {
type: String,
value: ''
},
},
data: {
IMG_URL,
topStats: [
{ label: '学习时长', key: 'studyHours' },
{ label: '完成课程数', key: 'completedCourses' },
{ label: '带教次数', key: 'coachingTimes' }
],
tabs: [
{ key: 'course', label: '课程学习' },
{ key: 'coach', label: '督导带教' }
],
activeTab: 0,
list: []
},
methods: {
_beginListRequest() {
this._listReqSeq = (this._listReqSeq || 0) + 1
return this._listReqSeq
},
_isLatestListRequest(seq) {
return seq === this._listReqSeq
},
_beginTopRequest() {
this._topReqSeq = (this._topReqSeq || 0) + 1
return this._topReqSeq
},
_isLatestTopRequest(seq) {
return seq === this._topReqSeq
},
reloadData() {
this.getData()
this.getStaticsData()
},
search(e) {
this.setData({
startDate: e.detail.startDay?.replace(/\//g, '-'),
endDate: e.detail.endDay?.replace(/\//g, '-'),
}, () => {
this.getData()
this.getStaticsData()
})
this.triggerEvent('datesave', {
scope: 'trainingExperience',
timeDimension: e.detail.timeDimension,
startDate: e.detail.startDay,
endDate: e.detail.endDay
}, { bubbles: true, composed: true })
},
getStaticsData() {
const seq = this._beginTopRequest()
let { detailInfo, startDate, endDate } = this.data
let params = {
businessType: detailInfo.scene || undefined,
startDate,
endDate,
sortField: 1,
sortOrder: 0,
storeManagerPhone: detailInfo?.employeePhone
}
api.getTrainingStaffList(params).then(res => {
if (!this._isLatestTopRequest(seq)) return
let { code, data, message } = res
if (code == 0) {
this.setData({
topInfo: data[0] || {}
})
} else {
wx.$util.showToast(message)
}
})
},
getData() {
const seq = this._beginListRequest()
let { activeTab, detailInfo, startDate, endDate } = this.data
let params = {
businessType: detailInfo?.scene,
storeManagerPhone: detailInfo.employeePhone,
startDate,
endDate,
trainingType: activeTab + 1
}
wx.$util.showLoading()
api.getTrainingExperienceList(params).then(res => {
if (!this._isLatestListRequest(seq)) return
wx.$util.hideLoading()
let { code, data, message } = res
if (code == 0) {
data?.forEach(val => {
val.completedTime = dayjs(val.completedTime).format('YYYY-MM-DD HH:mm:ss')
})
this.setData({
list: data
})
} else {
wx.$util.showToast(message)
}
}).catch(() => {
if (!this._isLatestListRequest(seq)) return
wx.$util.hideLoading()
})
},
onTabTap(e) {
const { index } = e.currentTarget.dataset || {}
if (index == this.data.activeTab) return
this.setData({ activeTab: index, list: [] }, () => {
this.getData()
})
},
onViewItem(e) {
const { item } = e.currentTarget.dataset || {}
wx.navigateTo({
url: `/packageCrew/pages/mentoring/mentoring?id=${item.taskId}`,
})
}
},
})