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