fix(approve): 修复审批流程中的用户ID获取问题

优化审批流程中用户ID的获取方式,确保在加载待办列表时使用正确的用户ID。同时添加调试日志和调整toast显示时长。
This commit is contained in:
砂糖
2026-04-14 13:36:52 +08:00
parent d8bc6525d2
commit bb6f7aed51
3 changed files with 25 additions and 17 deletions

View File

@@ -33,7 +33,7 @@
<!-- 空数据 --> <!-- 空数据 -->
<view v-else-if="todoList.length === 0" class="empty-container"> <view v-else-if="todoList.length === 0" class="empty-container">
<uni-icons type="empty" size="60" color="#909399"></uni-icons> <uni-icons type="empty" size="60" color="#909399"></uni-icons>
<view class="empty-text">暂无待审批任务</view> <view class="empty-text">暂无待审批任务</view>
</view> </view>
@@ -128,12 +128,15 @@
actionForm: { actionForm: {
remark: '' remark: ''
}, },
actionSubmitting: false actionSubmitting: false,
currentOaUserId: ''
} }
}, },
onShow() { onShow() {
this.loadEmployees(); this.fetchUserProfile().then(() => {
this.loadTodoList(); this.loadEmployees();
this.loadTodoList();
});
}, },
methods: { methods: {
// 格式化员工信息展示不展示各类ID // 格式化员工信息展示不展示各类ID
@@ -149,6 +152,7 @@
const user = response?.data?.user || {}; const user = response?.data?.user || {};
const roles = user.roles?.map(item => item.roleKey) || []; const roles = user.roles?.map(item => item.roleKey) || [];
this.$store.commit('oa/SET_STATE', user); this.$store.commit('oa/SET_STATE', user);
this.currentOaUserId = user.userId || '';
this.roleGroup = roles; this.roleGroup = roles;
return user; return user;
} catch (error) { } catch (error) {
@@ -284,18 +288,18 @@
async loadTodoList() { async loadTodoList() {
this.loading = true; this.loading = true;
try { try {
const profileUser = await this.fetchUserProfile(); // const profileUser = await this.fetchUserProfile();
const userId = this.resolveCurrentUserId(profileUser); // const userId = this.resolveCurrentUserId(profileUser);
if (!userId) { // if (!userId) {
this.todoList = []; // this.todoList = [];
this.todoCount = 0; // this.todoCount = 0;
uni.showToast({ // uni.showToast({
title: '当前登录信息未就绪,请稍后重试', // title: '当前登录信息未就绪,请稍后重试',
icon: 'none' // icon: 'none'
}); // });
return; // return;
} // }
const res = await listTodoFlowTask(userId); const res = await listTodoFlowTask(this.currentOaUserId);
let list = res.data || []; let list = res.data || [];
// 前端过滤 bizType // 前端过滤 bizType
if (this.query.bizType) { if (this.query.bizType) {

View File

@@ -206,6 +206,7 @@ export default {
uni.showToast({ uni.showToast({
icon: "success", icon: "success",
title: "缓存清除成功", title: "缓存清除成功",
duration: 1500
}); });
} }
}, },

View File

@@ -59,7 +59,10 @@
return this.bizTypeComponentMap[this.bizType] || ''; return this.bizTypeComponentMap[this.bizType] || '';
}, },
canApprove() { canApprove() {
return this.currentTask && this.currentTask.status === 'pending' && (this.currentTask?.assigneeUserName === this.$store.getters.storeOaName || this.currentTask?.assigneeUserId === this.$store.getters.storeOaId) console.log(this.currentTask, this.$store.getters.storeOaName, this.$store.getters.storeOaId)
return this.currentTask && this.currentTask.status === 'pending' &&
(this.currentTask?.assigneeUserName === this.$store.getters.storeOaName
|| this.currentTask?.assigneeUserId === this.$store.getters.storeOaId)
}, },
}, },
watch: { watch: {