修改了审批页面
This commit is contained in:
@@ -2,10 +2,6 @@
|
||||
<view class="hrm-page">
|
||||
<!-- 顶部统计栏 -->
|
||||
<view class="summary-bar">
|
||||
<view class="summary-left">
|
||||
<view class="page-title">审批中心</view>
|
||||
<view class="page-desc">集中查看与处理待办审批</view>
|
||||
</view>
|
||||
<view class="summary-right">
|
||||
<view class="metric">
|
||||
<view class="metric-value">{{ todoCount }}</view>
|
||||
@@ -136,47 +132,54 @@
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.loadEmployees();
|
||||
this.loadTodoList();
|
||||
},
|
||||
methods: {
|
||||
// 格式化员工信息展示
|
||||
// 格式化员工信息展示(不展示各类ID)
|
||||
formatEmpLabel(emp) {
|
||||
if (!emp) return '';
|
||||
const name = emp.empName || emp.nickName || emp.userName || '';
|
||||
const no = emp.empNo ? ` · ${emp.empNo}` : '';
|
||||
const dept = emp.deptName ? ` · ${emp.deptName}` : '';
|
||||
return `${name || '员工'}${no}${dept}`.trim();
|
||||
return `${name || '员工'}${dept}`.trim();
|
||||
},
|
||||
async fetchUserProfile() {
|
||||
console.log('fetchUserProfile方法开始执行');
|
||||
try {
|
||||
// this.loading = true;
|
||||
uni.showLoading()
|
||||
console.log('开始调用getUserProfile API');
|
||||
const response = await getUserProfile();
|
||||
//
|
||||
console.log('用户个人信息:', response);
|
||||
// 从接口返回数据中提取用户权限(roleKey)
|
||||
const roles = response.data.user?.roles?.map(item => item.roleKey) || [];
|
||||
this.$store.commit('oa/SET_STATE', response.data.user)
|
||||
console.log('用户权限字段', roles);
|
||||
this.roleGroup = roles;
|
||||
uni.hideLoading()
|
||||
} catch (error) {
|
||||
console.error('获取用户个人信息失败:', error);
|
||||
// 错误处理:可以设置默认权限或提示用户
|
||||
this.roleGroup = [];
|
||||
}
|
||||
try {
|
||||
const response = await getUserProfile();
|
||||
const user = response?.data?.user || {};
|
||||
const roles = user.roles?.map(item => item.roleKey) || [];
|
||||
this.$store.commit('oa/SET_STATE', user);
|
||||
this.roleGroup = roles;
|
||||
return user;
|
||||
} catch (error) {
|
||||
console.error('获取用户个人信息失败:', error);
|
||||
this.roleGroup = [];
|
||||
return null;
|
||||
}
|
||||
},
|
||||
// 格式化申请人信息
|
||||
// 格式化申请人信息(优先展示姓名,不展示ID)
|
||||
formatApplicant(task) {
|
||||
if (!task.bizData) return '加载中...';
|
||||
const empId = task.bizData.empId;
|
||||
if (!task) return '未指定';
|
||||
const biz = task.bizData || {};
|
||||
const directName =
|
||||
biz.empName ||
|
||||
biz.applicantName ||
|
||||
biz.userName ||
|
||||
biz.nickName ||
|
||||
task.empName ||
|
||||
task.applicantName ||
|
||||
task.userName ||
|
||||
task.nickName ||
|
||||
'';
|
||||
if (directName) {
|
||||
return directName;
|
||||
}
|
||||
const empId = biz.empId || task.empId;
|
||||
const emp = this.employees.find(e => String(e.empId) === String(empId));
|
||||
if (emp) {
|
||||
return this.formatEmpLabel(emp);
|
||||
}
|
||||
return empId ? `员工ID:${empId}` : '未指定';
|
||||
return '未指定';
|
||||
},
|
||||
// 格式化申请信息
|
||||
formatRequestInfo(task) {
|
||||
@@ -271,19 +274,25 @@
|
||||
this.employees = [];
|
||||
});
|
||||
},
|
||||
// 获取当前用户ID(优先 store,其次接口返回)
|
||||
resolveCurrentUserId(profileUser) {
|
||||
const storeId = this.$store?.getters?.storeOaId || this.$store?.state?.oa?.id;
|
||||
if (storeId) return storeId;
|
||||
return profileUser?.userId || profileUser?.id || profileUser?.empId || '';
|
||||
},
|
||||
// 加载待办列表
|
||||
async loadTodoList() {
|
||||
this.loading = true;
|
||||
try {
|
||||
await this.fetchUserProfile()
|
||||
const userId = this.$store?.getters.storeOaId;
|
||||
console.log(this.$store?.getters.storeOaId)
|
||||
const profileUser = await this.fetchUserProfile();
|
||||
const userId = this.resolveCurrentUserId(profileUser);
|
||||
if (!userId) {
|
||||
this.todoList = [];
|
||||
this.todoCount = 0;
|
||||
uni.showToast({
|
||||
title: '无法获取当前用户信息,请重新登录',
|
||||
icon: 'error'
|
||||
title: '当前登录信息未就绪,请稍后重试',
|
||||
icon: 'none'
|
||||
});
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
const res = await listTodoFlowTask(userId);
|
||||
@@ -295,17 +304,15 @@
|
||||
|
||||
this.todoList = list;
|
||||
this.todoCount = list.length;
|
||||
this.todayCount = 0; // 可根据实际需求实现今日处理数量统计
|
||||
this.todayCount = 0;
|
||||
} catch (err) {
|
||||
// console.error('加载待办任务失败:', err);
|
||||
|
||||
// uni.showToast({
|
||||
// title: '加载待办任务失败',
|
||||
// icon: 'error'
|
||||
// });
|
||||
this.loadTodoList();
|
||||
console.error('加载待办任务失败:', err);
|
||||
this.todoList = [];
|
||||
this.todoCount = 0;
|
||||
uni.showToast({
|
||||
title: '加载待办任务失败',
|
||||
icon: 'none'
|
||||
});
|
||||
} finally {
|
||||
this.loading = false;
|
||||
}
|
||||
@@ -426,20 +433,6 @@
|
||||
border-radius: 10rpx;
|
||||
background: #ffffff;
|
||||
|
||||
.summary-left {
|
||||
.page-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 800;
|
||||
color: #2b2f36;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.page-desc {
|
||||
margin-top: 8rpx;
|
||||
font-size: 24rpx;
|
||||
color: #8a8f99;
|
||||
}
|
||||
}
|
||||
|
||||
.summary-right {
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user