Files
qingcheng-xiaochengxu/pages/dashboardModule/staffPerformance/staffPerformance.js

116 lines
3.3 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { baseUrl } from "../../../request";
// pages/dashboardModule/supervisorPerformance/supervisorPerformance.js
Page({
data: {
nickName: '', // 主管名称
phoneNumber: '', // 手机号
showList: false, // 是否显示绩效列表
performanceList: [], // 绩效列表数据,含 ratePercent 字段
supervisorUserId: 0, // 上级主管id
},
onNameInput(e) {
this.setData({ nickName: e.detail.value });
},
onPhoneInput(e) {
this.setData({ phoneNumber: e.detail.value });
},
onSearch() {
const nickName = this.data.nickName.trim();
const phoneNumber = this.data.phoneNumber.trim();
const { supervisorUserId } = this.data;
wx.request({
url: baseUrl + '/perform/query/staff',
method: 'POST',
header: {
Authorization: wx.getStorageSync('token')
},
data: {
nickName: nickName,
phoneNumber: phoneNumber,
supervisorUserId: supervisorUserId,
},
success: (res) => {
console.log('--->后端返回记录',res.data);
if (res.data.code === 1) {
// 预处理:给每条记录加一个 ratePercent 字段
const listWithRate = res.data.data.map(item => {
const ratePercent = (item.rakeRewardsRate * 100).toFixed(2);
return Object.assign({}, item, { ratePercent });
});
// 分两次 setData不链
this.setData({ performanceList: listWithRate });
this.setData({ showList: true });
} else {
wx.showToast({ title: res.data.message || '查询失败', icon: 'none' });
}
},
fail: () => {
wx.showToast({ title: '网络错误', icon: 'none' });
}
});
},
// 全查
onSearchSupId() {
const { supervisorUserId } = this.data;
wx.request({
url: baseUrl + '/perform/query/staff',
method: 'POST',
header: {
Authorization: wx.getStorageSync('token')
},
data: { supervisorUserId },
success: (res) => {
console.log('--->后端返回记录',res.data);
if (res.data.code === 1) {
// 预处理:给每条记录加一个 ratePercent 字段
const listWithRate = res.data.data.map(item => {
const ratePercent = (item.rakeRewardsRate * 100).toFixed(2);
return Object.assign({}, item, { ratePercent });
});
// 分两次 setData不链
this.setData({ performanceList: listWithRate });
this.setData({ showList: true });
} else {
wx.showToast({ title: res.data.message || '查询失败', icon: 'none' });
}
},
fail: () => {
wx.showToast({ title: '网络错误', icon: 'none' });
}
});
},
onCopyPhone(e) {
const phone = e.currentTarget.dataset.phone;
wx.setClipboardData({
data: phone,
success() {
wx.showToast({ title: '手机号已复制', icon: 'success' });
}
});
},
onLoad(options) {
this.setData({
supervisorUserId: options.supId,
})
this.onSearchSupId();
},
// 跳转用户订单
gotoUser(e) {
const { id } = e.currentTarget.dataset;
wx.navigateTo({
url: `/pages/dashboardModule/userOrderPerformance/userOrderPerformance?userId=${id}`,
})
},
});