小程序提交
This commit is contained in:
@ -0,0 +1,97 @@
|
||||
import { baseUrl } from "../../../request";
|
||||
|
||||
// pages/dashboardModule/supervisorPerformance/supervisorPerformance.js
|
||||
Page({
|
||||
data: {
|
||||
nickName: '', // 主管名称
|
||||
phoneNumber: '', // 手机号
|
||||
showList: false, // 是否显示绩效列表
|
||||
performanceList: [], // 绩效列表数据,含 ratePercent 字段
|
||||
userRole: '', // 用户角色
|
||||
},
|
||||
|
||||
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();
|
||||
|
||||
if (!nickName) {
|
||||
wx.showToast({ title: '请输入主管名称', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
if (!/^1[3-9]\d{9}$/.test(phoneNumber)) {
|
||||
wx.showToast({ title: '请输入正确的手机号', icon: 'none' });
|
||||
return;
|
||||
}
|
||||
|
||||
wx.request({
|
||||
url: baseUrl + '/perform/query/supervisor',
|
||||
method: 'POST',
|
||||
header: {
|
||||
Authorization: wx.getStorageSync('token')
|
||||
},
|
||||
data: { nickName, phoneNumber },
|
||||
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) {
|
||||
console.log('--->',options);
|
||||
this.setData({
|
||||
userRole: options.role
|
||||
})
|
||||
let showRole = '';
|
||||
switch (options.role) {
|
||||
case 'manager':
|
||||
showRole = '主管';
|
||||
break;
|
||||
case 'supervisor':
|
||||
showRole = '员工';
|
||||
break;
|
||||
}
|
||||
this.setData({ showRole });
|
||||
},
|
||||
|
||||
changeStaff(e) {
|
||||
|
||||
const { id } = e.currentTarget.dataset;
|
||||
|
||||
wx.navigateTo({
|
||||
url: `/pages/dashboardModule/staffPerformance/staffPerformance?supId=${id}`,
|
||||
})
|
||||
},
|
||||
|
||||
});
|
Reference in New Issue
Block a user