fix(xispeak): 通过taskId精准获取当前分支局部变量impl_dept_id实现部门过滤

原先从formData.vars中读不到多实例局部变量,改为调用新增接口
getVariable,从task执行实例向上遍历获取impl_dept_id,确保每个
分支只过滤出本部门的反馈。

后端新增接口 GET /act/process/extActProcessNode/getVariable
支持 taskId + key + isLocal 参数,isLocal=true 时逐级向上查找
局部变量。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wsm
2026-06-29 15:55:35 +08:00
co-authored by Claude Opus 4.7
parent 1695036163
commit 2109ca083b
2 changed files with 49 additions and 11 deletions
@@ -277,7 +277,7 @@
import JTreeSelect from '/@/components/Form/src/jeecg/components/JTreeSelect.vue';
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import Icon from '/@/components/Icon/index';
import { bgXiSpeakFeedbackList, bgXiSpeakFeedbackListWithDept, bgXiSpeakFeedbackDelete, saveBpmForm, saveSubApprove } from '../BgXiSpeak.api';
import { bgXiSpeakFeedbackList, bgXiSpeakFeedbackDelete, saveBpmForm, saveSubApprove, getProcessVariable } from '../BgXiSpeak.api';
import { getUserList } from '/@/api/common/api';
import { usePermission } from '/@/hooks/web/usePermission';
import TaskHandleInnerContent from '/@/views/super/bpm/process/personalOffice/myHandleTask/content/TaskHandleInnerContent.vue';
@@ -577,15 +577,41 @@ import { PARTY_COMMITTEE_DEPT_ID, SDW_LEADER_ROLE_ID } from '/@/constant/supervi
}
}
function getProcessVarDeptIds(): string[] {
async function getProcessVarDeptIds(): Promise<string[]> {
const taskId = props.formData?.taskId;
console.log('【部门过滤】taskId:', taskId, 'processInstanceId:', processInfo.value.processInstanceId);
if (taskId) {
try {
const res = await getProcessVariable({ taskId, key: 'impl_dept_id', isLocal: true });
const value = res?.result?.value ?? res?.value;
if (value) {
const result = String(value).split(',').map((s: string) => s.trim()).filter(Boolean);
console.log('【部门过滤】从流程局部变量 impl_dept_id 获取到:', result);
return result;
}
} catch (e) {
console.log('【部门过滤】获取局部变量 impl_dept_id 失败:', e);
}
}
// 局部变量未找到,尝试从流程级变量获取
const vars = (props.formData?.vars ?? {}) as Record<string, any>;
const value = vars.implDept ?? vars.impl_dept_id ?? vars.pending_depts_id ?? vars.dept_id ?? vars.deptid;
if (!value) return [];
if (Array.isArray(value)) return value.map((v: any) => String(v).trim()).filter(Boolean);
return String(value)
.split(',')
.map((s: string) => s.trim())
.filter(Boolean);
console.log('【部门过滤】vars所有key:', Object.keys(vars), 'implDept:', vars.implDept, 'pending_depts_id:', vars.pending_depts_id);
const value = vars.implDept ?? vars.pending_depts_id ?? vars.dept_id ?? vars.deptid;
if (value) {
const result = Array.isArray(value)
? value.map((v: any) => String(v).trim()).filter(Boolean)
: String(value).split(',').map((s: string) => s.trim()).filter(Boolean);
console.log('【部门过滤】从流程级变量获取到部门ID:', result);
return result;
}
// 最终 fallback 到主表已保存的牵头部门
if (mainForm.implDept) {
const result = String(mainForm.implDept).split(',').map((s: string) => s.trim()).filter(Boolean);
console.log('【部门过滤】fallback mainForm.implDept:', result);
return result;
}
console.log('【部门过滤】未获取到任何部门ID');
return [];
}
function getCurrentUserDeptId() {
@@ -610,18 +636,22 @@ import { PARTY_COMMITTEE_DEPT_ID, SDW_LEADER_ROLE_ID } from '/@/constant/supervi
feedbackList.value = [];
return;
}
const apiFn = showDeptFeedback.value ? bgXiSpeakFeedbackListWithDept : bgXiSpeakFeedbackList;
const apiFn = bgXiSpeakFeedbackList;
const res = await apiFn({ mainId: mainForm.id, bpmProcessId, pageNo: 1, pageSize: 999 });
let list = res?.records || res?.result?.records || [];
console.log('【部门过滤】showDeptFeedback:', showDeptFeedback.value, '反馈总数:', list.length);
if (list.length && showDeptFeedback.value) {
const deptIds = getProcessVarDeptIds();
const deptIds = await getProcessVarDeptIds();
console.log('【部门过滤】用于过滤的部门ID列表:', deptIds);
if (deptIds.length) {
console.log('【部门过滤】过滤前各反馈的 responDeptid:', list.map((item: any) => ({ id: item.id, responDeptid: item.responDeptid, responDeptname: item.responDeptname })));
list = list.filter((item: any) => {
const responDeptIds = String(item.responDeptid || '')
.split(',')
.map((s: string) => s.trim());
return deptIds.some((id) => responDeptIds.includes(id));
});
console.log('【部门过滤】过滤后剩余:', list.map((item: any) => ({ id: item.id, responDeptid: item.responDeptid, responDeptname: item.responDeptname })));
}
}
feedbackList.value = list;