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

Merge pull request !65 from wsm/feature/20260629
This commit is contained in:
wsm
2026-06-29 07:58:57 +00:00
committed by Gitee
2 changed files with 49 additions and 11 deletions
+8
View File
@@ -134,6 +134,14 @@ export const bgXiSpeakFeedbackDelete = (params, handleSuccess) => {
});
};
/**
* 获取流程变量(支持局部变量查询),从task执行实例向上精准查找
* @param params { taskId, key, isLocal }
*/
export const getProcessVariable = (params: { taskId: string; key: string; isLocal?: boolean }) => {
return defHttp.get({ url: '/act/process/extActProcessNode/getVariable', params });
};
/**
* 子表批量删除
* @param params
@@ -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;